This commit is contained in:
jaime 2020-10-27 14:50:44 +00:00
parent 0cec617e8f
commit 326d2cbfe4
35 changed files with 12375 additions and 7326 deletions

View File

@ -1,8 +1,16 @@
TBD - 1.4
TODO:- New feature: eQSL syncronization
BUG: Chen pushing enter directly after clublog password is introduced, klog crashes
BUG: Too many mesages when uploading in realtime to Clublog. It should be done silently.
TODO:- New feature: QRZ.com sync - https://www.qrz.com/docs/logbook/QRZLogbookAPI.html
TODO:- New feature: eQSL syncronization - QSL Upload.
TODO:- New feature: eQSL syncronization - QSL Download.
TODO:- New feature: Regional Award support.
- New feature: - New feature: ClubLog log upload.
- Improved the KG4xx (Guantanamo bay) DXCC detection from KG4 calls.
- New feature: - New feature: ClubLog full log upload (adding or overwriting).
- New feature: It is possible to keep the comment field from one QSO to the following one. (TNX EA5WA)
- UI: Consolidation of all the electronic logs configurations in one single setup page into the eLog tab.
- Bugfix: Complete with previous QSO (name, locator, ...) was not working properly.
- Bugfix: PROGRAMID ADIF data was not properly tagged.
- Bugfix: When selecting the QSOs to upload to LoTW, if the selected call was the first one on the combobox, selection didn't worked properly.
- Bugfix: When importing ADIF files with fields without RST_SENT or RST_RCVD the proposed default value was not adapted to the mode of that QSO.

View File

@ -1,5 +1,6 @@
CONFIG += app_bundle
CONFIG += static
#CONFIG += console
CONFIG -=depend_includepath
#CONFIG += release
TEMPLATE = app
@ -46,7 +47,7 @@ HEADERS += setupdialog.h \
qso.h \ \
searchmodel.h \
searchwindow.h \
setuppages/setuppageeqsl.h \
setuppages/setuppageelog.h \
widgets/adiflotwexportwidget.h \
widgets/showadifimportwidget.h \
world.h \
@ -82,7 +83,6 @@ HEADERS += setupdialog.h \
hamlibclass.h \
tipsdialog.h \
worldmapwidget.h \
setuppages/setuppagelotw.h \
setuppages/setuppagemisc.h \
setuppages/setuppageuserdata.h \
setuppages/setuppagedxcluster.h \
@ -93,7 +93,6 @@ HEADERS += setupdialog.h \
setuppages/setuppagesatsnew.h \
setuppages/setuppagehamlib.h \
setuppages/setuppagelogsnew.h \
setuppages/setuppageclublog.h \
setuppages/setuppagebandmode.h \
setuppages/setupentitydialog.h \
setuppages/setuppageudp.h \
@ -124,7 +123,7 @@ SOURCES += main.cpp \
searchmodel.cpp \
searchwindow.cpp \
setupdialog.cpp \
setuppages/setuppageeqsl.cpp \
setuppages/setuppageelog.cpp \
widgets/adiflotwexportwidget.cpp \
widgets/showadifimportwidget.cpp \
world.cpp \
@ -136,7 +135,6 @@ SOURCES += main.cpp \
dxcluster.cpp \
locator.cpp \
awards.cpp \
setuppages/setuppagelotw.cpp \
setuppages/setuppagemisc.cpp \
setuppages/setuppageuserdata.cpp \
setuppages/setuppagedxcluster.cpp \
@ -144,7 +142,6 @@ SOURCES += main.cpp \
setuppages/setuppagelogs.cpp \
setuppages/setuppageworldeditor.cpp \
setuppages/setuppagelogsnew.cpp \
setuppages/setuppageclublog.cpp \
setuppages/setuppagebandmode.cpp \
setuppages/setuppageudp.cpp \
setuppages/setuppagesats.cpp \

View File

@ -1631,7 +1631,7 @@ QString DataProxy_SQLite::getCallFromId(const int _qsoId)
QStringList DataProxy_SQLite::getClubLogRealTimeFromId(const int _qsoId)
{
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: " << QString::number(_qsoId) << endl;
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: " << QString::number(_qsoId) << endl;
/* Return a QStringList with 16 fields with these data:
QSO_DATE, TIME_ON, QSLRDATE, QSLSDATE, CALL, OPERATOR, MODE, BAND, BAND_RX, FREQ, QSL_RCVD,
@ -1749,43 +1749,58 @@ LOTW_QSL_RCVD, QSL_SENT, DXCC, PROP_MODE, CREDIT_GRANTED
call = QString();
sqlOk = query2.exec(queryString);
QSqlRecord rec = query.record();
rec = query2.record();
QSqlRecord rec = query2.record();
//rec = query2.record();
if (sqlOk)
{
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId OK2" << endl;
if (query2.next())
{
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId NEXT OK2" << endl;
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId - query: " << query2.lastQuery() << endl;
if (query2.isValid())
{
QString auxx;
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId VALID OK2" << endl;
nameCol = rec.indexOf("qso_date");
auxx = util->getADIFDateFromQDateTime(util->getDateTimeFromSQLiteString((query.value(nameCol)).toString()));
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId VALID OK2: " << auxx << endl;
dataC << auxx;
dataC << util->getADIFDateFromQDateTime(util->getDateTimeFromSQLiteString((query.value(nameCol)).toString()));
if (nameCol>=0)
{
auxx = util->getADIFDateFromQDateTime(util->getDateTimeFromSQLiteString((query2.value(nameCol)).toString()));
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId VALID OK2: " << auxx << endl;
dataC << auxx;
dataC << util->getADIFDateFromQDateTime(util->getDateTimeFromSQLiteString((query2.value(nameCol)).toString()));
auxx = util->getADIFTimeFromQDateTime(util->getDateTimeFromSQLiteString((query.value(nameCol)).toString()));
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId VALID OK2: " << auxx << endl;
dataC << auxx;
dataC << util->getADIFTimeFromQDateTime(util->getDateTimeFromSQLiteString((query.value(nameCol)).toString()));
auxx = util->getADIFTimeFromQDateTime(util->getDateTimeFromSQLiteString((query2.value(nameCol)).toString()));
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId VALID OK2: " << auxx << endl;
dataC << auxx;
dataC << util->getADIFTimeFromQDateTime(util->getDateTimeFromSQLiteString((query2.value(nameCol)).toString()));
}
nameCol = rec.indexOf("qslrdate");
dataC << util->getADIFDateFromQDate( util->getDateFromSQliteString((query.value(nameCol)).toString()) );
//dataC << (query2.value(nameCol)).toString();
if (nameCol>=0)
{
dataC << util->getADIFDateFromQDate( util->getDateFromSQliteString((query2.value(nameCol)).toString()) );
//dataC << (query2.value(nameCol)).toString();
}
nameCol = rec.indexOf("qslsdate");
dataC << util->getADIFDateFromQDate( util->getDateFromSQliteString((query.value(nameCol)).toString()) );
if (nameCol>=0)
{
dataC << util->getADIFDateFromQDate( util->getDateFromSQliteString((query2.value(nameCol)).toString()) );
}
//dataC << (query2.value(nameCol)).toString();
nameCol = rec.indexOf("call");
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId VALID OK2: " << call << endl;
call = (query2.value(nameCol)).toString();
dataC << call;
if (nameCol>=0)
{
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId VALID OK2: " << call << endl;
call = (query2.value(nameCol)).toString();
dataC << call;
}
nameCol = rec.indexOf("operator");
dataC << (query2.value(nameCol)).toString();
if (nameCol>=0)
{
dataC << (query2.value(nameCol)).toString();
}
//nameCol = rec.indexOf("M.name"); //TODO: Fix this to get the proper column
dataC << (query2.value(6)).toString(); // Mode is column 6
@ -1797,31 +1812,54 @@ LOTW_QSL_RCVD, QSL_SENT, DXCC, PROP_MODE, CREDIT_GRANTED
dataC << "";
nameCol = rec.indexOf("freq");
dataC << (query2.value(nameCol)).toString();
if (nameCol>=0)
{
dataC << (query2.value(nameCol)).toString();
}
nameCol = rec.indexOf("qsl_rcvd");
dataC << (query2.value(nameCol)).toString();
if (nameCol>=0)
{
dataC << (query2.value(nameCol)).toString();
}
nameCol = rec.indexOf("lotw_qsl_rcvd");
dataC << (query2.value(nameCol)).toString();
if (nameCol>=0)
{
dataC << (query2.value(nameCol)).toString();
}
nameCol = rec.indexOf("qsl_sent");
dataC << (query2.value(nameCol)).toString();
if (nameCol>=0)
{
dataC << (query2.value(nameCol)).toString();
}
nameCol = rec.indexOf("dxcc");
dataC << (query2.value(nameCol)).toString();
if (nameCol>=0)
{
dataC << (query2.value(nameCol)).toString();
}
nameCol = rec.indexOf("prop_mode");
dataC << (query2.value(nameCol)).toString();
if (nameCol>=0)
{
dataC << (query2.value(nameCol)).toString();
}
nameCol = rec.indexOf("credit_granted");
dataC << (query2.value(nameCol)).toString();
if (nameCol>=0)
{
dataC << (query2.value(nameCol)).toString();
}
aux2 = QString();
nameCol = rec.indexOf("station_callsign");
aux2 = (query2.value(nameCol)).toString();
if (aux2.length()>2)
if (nameCol>=0)
{
dataC << aux2;
aux2 = (query2.value(nameCol)).toString();
if (aux2.length()>2)
{
dataC << aux2;
}
else
{
dataC << "";
}
}
else
{
dataC << "";
}
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: RETURNING ... OK" << endl;
query2.finish();
@ -1878,7 +1916,7 @@ QString DataProxy_SQLite::getNameFromQRZ(const QString &_call)
{
if (_call.length() <= 0)
{
//qDebug() << "DataProxy_SQLite::getNameFromQRZ return 0" << endl;
//qDebug() << "DataProxy_SQLite::getNameFromQRZ return 0" << endl;
return QString();
}
@ -1895,7 +1933,7 @@ QString DataProxy_SQLite::getNameFromQRZ(const QString &_call)
{
if (((query.value(0)).toString()).length()>0)
{
//qDebug() << "DataProxy_SQLite::getNameFromQRZ: " << (query.value(0)).toString() << endl;
//qDebug() << "DataProxy_SQLite::getNameFromQRZ: " << (query.value(0)).toString() << endl;
QString v = (query.value(0)).toString();
query.finish();
return v;
@ -1903,6 +1941,7 @@ QString DataProxy_SQLite::getNameFromQRZ(const QString &_call)
}
}
query.finish();
//qDebug() << "DataProxy_SQLite::getNameFromQRZ: NO NAME" << endl;
return QString();
}
else
@ -2139,7 +2178,73 @@ bool DataProxy_SQLite::clublogSentQSOs(const QList<int> &_qsos)
return false;
}
bool DataProxy_SQLite::addQSOFromWSJTX (const QString &_dxcall, const QString &_mode, const QString &_band, const double _freq,
bool DataProxy_SQLite::eQSLModifyFullLog(const int _currentLog)
{
//qDebug() << " DataProxy_SQLite::eQSLModifyFullLog" << QString::number(_currentLog) << endl;
if (!doesThisLogExist(_currentLog))
{
return false;
}
QString queryString;
bool sqlOK;
QSqlQuery query;
queryString = QString("UPDATE log SET eqsl_qsl_sent = 'Q', eqsl_qslsdate = '%1'").arg(util->getDateSQLiteStringFromDate(QDate::currentDate()));
sqlOK = query.exec(queryString);
query.finish();
if (sqlOK)
{
//qDebug() << " DataProxy_SQLite::eQSLModifyFullLog: END TRUE" << endl;
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().number(), query.lastQuery());
//qDebug() << " DataProxy_SQLite::eQSLModifyFullLog: END FALSE: " << query.lastError().databaseText() << endl;
return false;
}
//qDebug() << " DataProxy_SQLite::eQSLModifyFullLog: END TRUE" << endl;
return false;
}
bool DataProxy_SQLite::eQSLSentQSOs(const QList<int> &_qsos)
{
//qDebug() << " DataProxy_SQLite::eQSLSentQSOs" << QString::number(_qsos.count()) << endl;
if (_qsos.count() < 1)
{
return true;
}
QString queryString;
bool sqlOK;
QSqlQuery query;
for (int i = 0; i< _qsos.count(); i++)
{
//qDebug() << " DataProxy_SQLite::eQSLSentQSOs: updating QSO: " << QString::number(_qsos.at(i)) << endl;
queryString = QString("UPDATE log SET eqsl_qsl_sent = 'Y', eqsl_qslsdate = '%1' WHERE id='%2'").arg(util->getDateSQLiteStringFromDate(QDate::currentDate())).arg(QString::number(_qsos.at(i)));
sqlOK = query.exec(queryString);
query.finish();
if (sqlOK)
{
//qDebug() << " DataProxy_SQLite::eQSLSentQSOs: exec: " << query.lastQuery() << endl;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().number(), query.lastQuery());
//qDebug() << " DataProxy_SQLite::eQSLSentQSOs: END FALSE" << endl;
return false;
}
}
//qDebug() << " DataProxy_SQLite::eQSLSentQSOs: END TRUE" << endl;
return true;
}
bool DataProxy_SQLite::addQSOFromWSJTX (const QString &_dxcall, const QString &_mode, const QString &_band, const double _freq,
const QString &_mygrid, const QString &_dxgrid,
const QString &_rstTX, const QString &_rstRX, const QString &_sRX, const QString &_sTX,
const QString &_comment,
@ -3330,6 +3435,88 @@ QList<int> DataProxy_SQLite::getQSOsListClubLogToSent(const QString &_stationCal
//qDebug() << "DataProxy_SQLite::getQSOsListClubLogToSent QSO Date: " << aux << "/" << tmpDate.toString("yyyy-MM-dd") << endl;
//tmpDate = QDate::fromString(aux, "yyyy-MM-dd");
if ((_startDate<=tmpDate) && _endDate>=tmpDate)
{
//qDebug() << "DataProxy_SQLite::getQSOsListClubLogToSent Adding: " << QString::number((query.value(0)).toInt()) << endl;
qsoList.append((query.value(0)).toInt());
}
}
else
{
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().number(), query.lastQuery());
query.finish();
qsoList.clear();
return qsoList;
}
query.finish();
qs.sort();
//qDebug() << "DataProxy_SQLite::getQSOsListClubLogToSent Returning: #" << QString::number(qsoList.length()) << endl;
return qsoList;
}
QList<int> DataProxy_SQLite::getQSOsListEQSLToSent(const QString &_stationCallsign, const QDate &_startDate, const QDate &_endDate, bool _justModified)
{
//qDebug() << "DataProxy_SQLite::getQSOsListEQSLToSent Call/Start/end: " << _stationCallsign << _startDate.toString("yyyyMMdd") << "/" << _endDate.toString("yyyyMMdd") << endl;
QList <int> qsoList;
qsoList.clear();
QDate tmpDate;
QString aux = QString();
QStringList qs;
qs.clear();
QString queryString;
QString _queryST_string;
if (util->isValidCall(_stationCallsign))
{
_queryST_string = QString("station_callsign='%1'").arg(_stationCallsign);
}
else if (_stationCallsign == "ALL")
{
_queryST_string = QString("station_callsign!='ALL'");
}
else
{
_queryST_string = QString("station_callsign=''");
}
QString _query_justModified;
if (_justModified)
{
//qDebug() << "DataProxy_SQLite::getQSOsListEQSLToSent justQueued TRUE" << endl;
_query_justModified = QString("eqsl_qsl_sent='Q'");
}
else
{
//qDebug() << "DataProxy_SQLite::getQSOsListEQSLToSent justQueued FALSE" << endl;
_query_justModified = QString("eqsl_qsl_sent=!='M'");
}
queryString = QString("SELECT id, qso_date FROM log WHERE ") + _queryST_string + " AND " + _query_justModified;
QSqlQuery query;
bool sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::getQSOsListEQSLToSent Query: " << query.lastQuery() << endl;
if (sqlOK)
{
// //qDebug() << "DataProxy_SQLite::getQSOsListEQSLToSent Query: " << query.lastQuery() << endl;
while ( (query.next())) {
if (query.isValid())
{
aux.clear();
aux = (query.value(1)).toString() ;
tmpDate = util->getDateFromSQliteString(aux);
//qDebug() << "DataProxy_SQLite::getQSOsListEQSLToSent QSO Date: " << aux << "/" << tmpDate.toString("yyyy-MM-dd") << endl;
//tmpDate = QDate::fromString(aux, "yyyy-MM-dd");
if ((_startDate<=tmpDate) && _endDate>=tmpDate)
{
qsoList.append((query.value(0)).toInt());
}
@ -3351,6 +3538,89 @@ QList<int> DataProxy_SQLite::getQSOsListClubLogToSent(const QString &_stationCal
return qsoList;
}
QList<int> DataProxy_SQLite::getQSOsListeQSLNotSent(const QString &_stationCallsign, const QDate &_startDate, const QDate &_endDate, bool _justQueued)
{
//qDebug() << "DataProxy_SQLite::getQSOsListeQSLNotSent Call/Start/end: " << _stationCallsign << _startDate.toString("yyyyMMdd") << "/" << _endDate.toString("yyyyMMdd") << endl;
QList <int> qsoList;
qsoList.clear();
QDate tmpDate;
QString aux = QString();
QStringList qs;
qs.clear();
QString queryString;
QString _queryST_string;
if (util->isValidCall(_stationCallsign))
{
_queryST_string = QString("station_callsign='%1'").arg(_stationCallsign);
}
else if (_stationCallsign == "ALL")
{
_queryST_string = QString("station_callsign!='ALL'");
}
else
{
_queryST_string = QString("station_callsign=''");
}
QString _query_justQueued;
if (_justQueued)
{
//qDebug() << "DataProxy_SQLite::getQSOsListeQSLNotSent justQueued TRUE" << endl;
_query_justQueued = QString("eqsl_qsl_sent='Q'");
}
else
{
//qDebug() << "DataProxy_SQLite::getQSOsListeQSLNotSent justQueued FALSE" << endl;
_query_justQueued = QString("eqsl_qsl_sent!='1'");
}
queryString = QString("SELECT id, qso_date FROM log WHERE ") + _queryST_string + " AND " + _query_justQueued;
QSqlQuery query;
bool sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::getQSOsListeQSLNotSent Query: " << query.lastQuery() << endl;
if (sqlOK)
{
// //qDebug() << "DataProxy_SQLite::getQSOsListeQSLNotSent Query: " << query.lastQuery() << endl;
while ( (query.next())) {
if (query.isValid())
{
aux.clear();
aux = (query.value(1)).toString() ;
tmpDate = util->getDateFromSQliteString(aux);
//qDebug() << "DataProxy_SQLite::getQSOsListLoTWNotSent QSO Date: " << aux << "/" << tmpDate.toString("yyyy-MM-dd") << endl;
//tmpDate = QDate::fromString(aux, "yyyy-MM-dd");
if ((_startDate<=tmpDate) && _endDate>=tmpDate)
{
qsoList.append((query.value(0)).toInt());
}
}
else
{
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().number(), query.lastQuery());
query.finish();
qsoList.clear();
return qsoList;
}
query.finish();
qs.sort();
return qsoList;
}
QStringList DataProxy_SQLite::getQSODetailsForLoTWDownload(const int _id)
{ //Returns QRZ << date+time << Band (txt) << mode (txt)
//qDebug() << "DataProxy_SQLite::getQSODetailsForLoTWDownload" << QString::number(_id) << endl;

View File

@ -137,6 +137,12 @@ public:
bool updateAwardDXCC();
bool updateAwardWAZ();
//EQSL
bool eQSLModifyFullLog(const int _currentLog); // Mark all the log as modified to be sent to eQSL
bool eQSLSentQSOs(const QList<int> &_qsos); // Mark as uploaded
//EQSL
//CLUBLOG
bool clublogSentQSOs(const QList<int> &_qsos); // Mark as uploaded
bool clublogModifyFullLog(const int _currentLog); // Mark all the log as modified to be sent to CLubLog
@ -152,7 +158,10 @@ public:
QStringList getQSOsListLoTWNotSent2(const QString &_stationCallsign, const QDate &_startDate, const QDate &_endDate, bool _justQueued=true);
QStringList getQSODetailsForLoTWDownload(const int _id);
QList<int> getQSOsListeQSLNotSent(const QString &_stationCallsign, const QDate &_startDate, const QDate &_endDate, bool _justQueued=true);
QList<int> getQSOsListClubLogToSent(const QString &_stationCallsign, const QDate &_startDate, const QDate &_endDate, bool _justModified=true);
QList<int> getQSOsListEQSLToSent(const QString &_stationCallsign, const QDate &_startDate, const QDate &_endDate, bool _justModified=true);
int getContinentIdFromContinentShortName(const QString &_n);
QString getContinentShortNameFromEntity(const int _n);

View File

@ -9,7 +9,7 @@
eLogClubLog::eLogClubLog()
{
//qDebug() << "eLogClubLog::eLogClubLog" << endl;
//qDebug()<< "eLogClubLog::eLogClubLog" << endl;
email = QString();
pass = QString();
@ -20,21 +20,22 @@ eLogClubLog::eLogClubLog()
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotQsoUploadFinished(QNetworkReply*)));
stationCallsign = QString();
uploadingFile = false;
//qDebug() << "eLogClubLog::eLogClubLog - END" << endl;
util = new Utilities;
//qDebug()<< "eLogClubLog::eLogClubLog - END" << endl;
}
eLogClubLog::~eLogClubLog()
{
//qDebug() << "eLogClubLog::~eLogClubLog" << endl;
//qDebug()<< "eLogClubLog::~eLogClubLog" << endl;
}
void eLogClubLog::slotQsoUploadFinished(QNetworkReply *data)
{
//qDebug() << "eLogClubLog::slotQsoUploadFinished" << endl;
//qDebug()<< "eLogClubLog::slotQsoUploadFinished" << endl;
result = data->error();
//qDebug() << "eLogClubLog::slotQsoUploadFinished - Result = " << QString::number(result) << endl;
//qDebug()<< "eLogClubLog::slotQsoUploadFinished - Result = " << QString::number(result) << endl;
const QByteArray sdata = data->readAll();
@ -51,29 +52,31 @@ eLogClubLog::~eLogClubLog()
{
text = "ClubLog: " + prepareToTranslate(sdata);
//qDebug() << sdata;
//qDebug() << "eLogClubLog::slotQsoUploadFinished - NO ERROR" << endl;
//qDebug()<< sdata;
//qDebug()<< "eLogClubLog::slotQsoUploadFinished - NO ERROR" << endl;
if (uploadingFile)
{
uploadingFile = false;
emit signalFileUploaded(QNetworkReply::NoError, qsos);
emit signalFileUploaded(result, qsos);
qsos.clear();
return;
}
}
else if (result == QNetworkReply::HostNotFoundError)
{
//qDebug() << "eLogClubLog::slotQsoUploadFinished - Result = Host Not found! = " << QString::number(result) << endl;
//qDebug()<< "eLogClubLog::slotQsoUploadFinished - Result = Host Not found! = " << QString::number(result) << endl;
text = "ClubLog: " + tr("Host not found!");
//TODO: Mark the previous QSO as not sent to clublog
}
else if (result == QNetworkReply::TimeoutError)
{
//qDebug() << "eLogClubLog::slotQsoUploadFinished - Result = Time out error! = " << QString::number(result) << endl;
//qDebug()<< "eLogClubLog::slotQsoUploadFinished - Result = Time out error! = " << QString::number(result) << endl;
text = "ClubLog: " + tr("Timeout error!");
//TODO: Mark the previous QSO as not sent to clublog
}
/*
else if (result == 201)
{
text = "ClubLog: " + tr("It seems to be a CREDENTIALS ERROR; check your email and password.");
@ -86,7 +89,7 @@ eLogClubLog::~eLogClubLog()
}
else if (result == 202)
{
//qDebug() << "eLogClubLog::slotQsoUploadFinished - Result = Password Error! = " << QString::number(result) << endl;
//qDebug()<< "eLogClubLog::slotQsoUploadFinished - Result = Password Error! = " << QString::number(result) << endl;
text = "ClubLog: " + tr("It seems to be a PASSWORD ERROR; check your password.");
int i = QMessageBox::warning(nullptr, tr("KLog - ClubLog"),
@ -97,29 +100,36 @@ eLogClubLog::~eLogClubLog()
emit disableClubLogAction(true);
//TODO: Mark the previous QSO as not sent to clublog
}
else if (result == 203)
{
QSO DUPE?
}
*/
else
{
//qDebug() << "eLogClubLog::slotQsoUploadFinished - Result = UNDEFINED = " << QString::number(result) << endl;
text = "ClubLog: " + tr("Undefined error...");
//qDebug()<< "eLogClubLog::slotQsoUploadFinished - Result = UNDEFINED = " << QString::number(result) << endl;
text = "ClubLog: " + tr("Undefined error number (#%1)... ").arg(result);
int i = QMessageBox::warning(nullptr, tr("KLog - ClubLog"),
tr("We have received an undefined error from Clublog") + "\n" +
tr("We have received an undefined error from Clublog (%1)").arg(result) + "\n" +
tr("Please check your config in the setup and contact the KLog development team if you can't fix it. ClubLog uploads will be disabled."),
QMessageBox::Ok);
//TODO: Mark the previous QSO as not sent to clublog
}
//qDebug() << "eLogClubLog::slotQsoUploadFinished - Result = " << QString::number(result) << endl;
//qDebug()<< "eLogClubLog::slotQsoUploadFinished - Result = " << QString::number(result) << endl;
//qDebug()<< "eLogClubLog::slotQsoUploadFinished - Result Text = " << text << endl;
//emit done();
emit showMessage(text);
emit signalFileUploaded(result, qsos);
emit showMessage(text);
}
void eLogClubLog::slotFileUploadFinished(QNetworkReply *data)
{
//qDebug() << "eLogClubLog::slotFileUploadFinished" << endl;
//qDebug()<< "eLogClubLog::slotFileUploadFinished" << endl;
result = data->error();
//qDebug() << "eLogClubLog::slotFileUploadFinished - Result = " << QString::number(result) << endl;
//qDebug()<< "eLogClubLog::slotFileUploadFinished - Result = " << QString::number(result) << endl;
const QByteArray sdata = data->readAll();
@ -130,42 +140,42 @@ void eLogClubLog::slotFileUploadFinished(QNetworkReply *data)
{
text = "ClubLog: " + prepareToTranslate(sdata);
//qDebug() << "eLogClubLog::slotFileUploadFinished - Result = NoError = " << QString::number(result) << endl;
//qDebug() << sdata;
//qDebug()<< "eLogClubLog::slotFileUploadFinished - Result = NoError = " << QString::number(result) << endl;
//qDebug()<< sdata;
}
else if (result == QNetworkReply::HostNotFoundError)
{
//qDebug() << "eLogClubLog::slotFileUploadFinished - Result = Host Not found! = " << QString::number(result) << endl;
//qDebug()<< "eLogClubLog::slotFileUploadFinished - Result = Host Not found! = " << QString::number(result) << endl;
text = "ClubLog: " + tr("Host not found!");
}
else if (result == QNetworkReply::TimeoutError)
{
//qDebug() << "eLogClubLog::slotFileUploadFinished - Result = Time out error! = " << QString::number(result) << endl;
//qDebug()<< "eLogClubLog::slotFileUploadFinished - Result = Time out error! = " << QString::number(result) << endl;
text = "ClubLog: " + tr("Timeout error!");
}
else
{
//qDebug() << "eLogClubLog::slotFileUploadFinished - Result = UNDEFINED = " << QString::number(result) << endl;
//qDebug()<< "eLogClubLog::slotFileUploadFinished - Result = UNDEFINED = " << QString::number(result) << endl;
text = "ClubLog: " + tr("Undefined error...");
}
//qDebug() << "eLogClubLog::slotFileUploadFinished - Result = " << QString::number(result) << endl;
//qDebug()<< "eLogClubLog::slotFileUploadFinished - Result = " << QString::number(result) << endl;
//emit done();
emit showMessage(text);
}
void eLogClubLog::downloadProgress(qint64 received, qint64 total) {
//qDebug() << "eLogClubLog::downloadProgress: " << QString::number(received) << "/" << QString::number(total) << endl;
//qDebug()<< "eLogClubLog::downloadProgress: " << QString::number(received) << "/" << QString::number(total) << endl;
//qDebug() << received << total;
//qDebug()<< received << total;
emit actionShowProgres(received, total);
}
void eLogClubLog::slotErrorManagement(QNetworkReply::NetworkError networkError)
{
//qDebug() << "eLogClubLog::slotErrorManagement: " << QString::number(networkError) << endl;
//qDebug()<< "eLogClubLog::slotErrorManagement: " << QString::number(networkError) << endl;
result = networkError;
if (result == QNetworkReply::NoError)
@ -173,11 +183,11 @@ void eLogClubLog::slotErrorManagement(QNetworkReply::NetworkError networkError)
}
else if (result == QNetworkReply::HostNotFoundError)
{
//qDebug() << "eLogClubLog::slotErrorManagement: Host not found" << endl;
//qDebug()<< "eLogClubLog::slotErrorManagement: Host not found" << endl;
}
else
{
//qDebug() << "eLogClubLog::slotErrorManagement: ERROR!" << endl;
//qDebug()<< "eLogClubLog::slotErrorManagement: ERROR!" << endl;
}
//actionError(result);
@ -187,29 +197,26 @@ void eLogClubLog::slotErrorManagement(QNetworkReply::NetworkError networkError)
int eLogClubLog::sendQSO(QStringList _qso)
{
//qDebug() << "eLogClubLog::sendQSO: " << email << "/" << pass << "/" << api << endl;
//qDebug() << "eLogClubLog::sendQSO:: length = " << QString::number(_qso.length()) << endl;
//qDebug()<< "eLogClubLog::sendQSO:: length = " << QString::number(_qso.length()) << endl;
// First Data in the QStringList is the QSO id, not to be sent to clublog but used in the signal actionReturnDownload(const int _i, const int _qsoId);
//for(int i = 0; i<_qso.length(); i++)
//{
// //qDebug() << "eLogClubLog::sendQSO = qso-at: "<< QString::number(i) << "- " << _qso.at(i) << endl;
// //qDebug()<< "eLogClubLog::sendQSO = qso-at: "<< QString::number(i) << "- " << _qso.at(i) << endl;
// }
if (_qso.length()!=18)
{
//qDebug() << "eLogClubLog::sendQSO:: length" << endl;
//qDebug() << "eLogClubLog::sendQSO:: length - END" << endl;
return -1;
}
for (int i = 0; i< _qso.length(); i++)
{
//qDebug() << QString("eLogClubLog::sendQSO: (%1): %2").arg(i).arg(_qso.at(i)) << endl;
}
//for (int i = 0; i< _qso.length(); i++)
//{
//qDebug()<< QString("eLogClubLog::sendQSO: (%1): %2").arg(i).arg(_qso.at(i)) << endl;
//}
currentQSO = (_qso.at(0)).toInt();
//QStringList qso;
//qso.clear();
//qso << _qso;
_qso.removeFirst();
//_qso.removeFirst();
//qDebug() << "eLogClubLog::sendQSO CALL TO USE (before checking): " << _qso.at(16) << endl;
//qDebug() << "eLogClubLog::sendQSO default StationCallsign): " << stationCallsign << endl;
//qDebug()<< "eLogClubLog::sendQSO CALL TO USE (before checking): " << _qso.at(16) << endl;
//qDebug()<< "eLogClubLog::sendQSO default StationCallsign): " << stationCallsign << endl;
QString tempCall = _qso.at(16);
if (tempCall.length()<1)
@ -221,15 +228,16 @@ int eLogClubLog::sendQSO(QStringList _qso)
//stationCallsign = call;
//qDebug() << "eLogClubLog::sendQSO CALL TO USE: " << tempCall << endl;
//qDebug()<< "eLogClubLog::sendQSO CALL TO USE: " << tempCall << endl;
_qso.removeLast();
QString qso = getClubLogAdif(_qso);
//qDebug() << "eLogClubLog::sendQSO: " << qso << endl;
//qDebug()<< "eLogClubLog::sendQSO: " << qso << endl;
QUrlQuery params;
params.addQueryItem("adif",qso);
//qDebug() << "eLogClubLog::sendQSO: END" << endl;
return sendDataParams(tempCall, params, true);
//return sendData(tempCall, qso);
@ -237,7 +245,7 @@ int eLogClubLog::sendQSO(QStringList _qso)
/*
int eLogClubLog::deleteQSOid(const int _qsoId)
{
//qDebug() << "eLogClubLog::deleteQSOid: " << QString::number(_qsoId) << endl;
//qDebug()<< "eLogClubLog::deleteQSOid: " << QString::number(_qsoId) << endl;
// email, password, callsign, dxcall, datetime, bandid, api
QString dxcall, datatime, bandid;
QUrlQuery params;
@ -248,10 +256,10 @@ int eLogClubLog::deleteQSOid(const int _qsoId)
int eLogClubLog::sendDataParams(const QString &_clublogCall, const QUrlQuery &_params, bool _adding)
{
//qDebug() << "eLogClubLog::sendDataParams: Call: " << _clublogCall << endl;
//qDebug() << "eLogClubLog::sendDataParams: Params: " << _params.query(QUrl::FullyEncoded).toUtf8() << endl;
//qDebug() << "eLogClubLog::sendDataParams: email = " << email << endl;
//qDebug() << "eLogClubLog::sendDataParams: Pass = " << pass << endl;
//qDebug()<< "eLogClubLog::sendDataParams: Call: " << _clublogCall << endl;
//qDebug()<< "eLogClubLog::sendDataParams: Params: " << _params.query(QUrl::FullyEncoded).toUtf8() << endl;
//qDebug()<< "eLogClubLog::sendDataParams: email = " << email << endl;
//qDebug()<< "eLogClubLog::sendDataParams: Pass = " << pass << endl;
QUrl serviceUrl;
if (_adding)
@ -272,14 +280,14 @@ int eLogClubLog::sendDataParams(const QString &_clublogCall, const QUrlQuery &_p
if (_clublogCall.length()>2)
{
params.addQueryItem("callsign",_clublogCall);
//qDebug() << "eLogClubLog::sendDataParams - callsign 1: " << _clublogCall << endl;
//qDebug()<< "eLogClubLog::sendDataParams - callsign 1: " << _clublogCall << endl;
}
else
{
params.addQueryItem("callsign",stationCallsign);
}
//qDebug() << "eLogClubLog::sendDataParams - query before send/delete: " << params.query(QUrl::FullyEncoded).toUtf8() << endl;
//qDebug()<< "eLogClubLog::sendDataParams - query before send/delete: " << params.query(QUrl::FullyEncoded).toUtf8() << endl;
if (_adding)
{
params.addQueryItem("api",api);
@ -307,14 +315,14 @@ int eLogClubLog::sendDataParams(const QString &_clublogCall, const QUrlQuery &_p
manager->post(request, postData);
//qDebug()<< "eLogClubLog::sendDataParams - END" << endl;
return -1;
}
/*
int eLogClubLog::sendData(const QString &_clublogCall, const QString &_q)
{
//qDebug() << "eLogClubLog::sendData: " << _q << endl;
//qDebug()<< "eLogClubLog::sendData: " << _q << endl;
QUrl serviceUrl = QUrl("https://secure.clublog.org/realtime.php");
QByteArray postData;
@ -327,7 +335,7 @@ int eLogClubLog::sendData(const QString &_clublogCall, const QString &_q)
if (_clublogCall.length()>2)
{
params.addQueryItem("callsign",_clublogCall);
//qDebug() << "eLogClubLog::sendData - callsign 1: " << _clublogCall << endl;
//qDebug()<< "eLogClubLog::sendData - callsign 1: " << _clublogCall << endl;
}
else
{
@ -339,7 +347,7 @@ int eLogClubLog::sendData(const QString &_clublogCall, const QString &_q)
params.addQueryItem("adif",_q);
postData = params.query(QUrl::FullyEncoded).toUtf8();
//qDebug() << "eLogClubLog::sendData - query: " << postData << endl;
//qDebug()<< "eLogClubLog::sendData - query: " << postData << endl;
//postData = params.encodedQuery();
// Call the webservice
@ -356,7 +364,7 @@ int eLogClubLog::sendData(const QString &_clublogCall, const QString &_q)
}
*/
QString eLogClubLog::getClubLogAdif(const QStringList _q)
{
@ -391,46 +399,47 @@ NOTES
}
for (int i = 0; i< _q.length(); i++)
{
//qDebug() << QString("eLogClubLog::getClubLogAdif: (%1): %2").arg(i).arg(_q.at(i)) << endl;
//qDebug()<< QString("eLogClubLog::getClubLogAdif: (%1): %2").arg(i).arg(_q.at(i)) << endl;
}
QString qso, aux1;
qso.clear();
aux1 = _q.at(0);
//qDebug() << "eLogClubLog::getClubLogAdif: Date: " << _q.at(0) << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: Date: " << _q.at(0) << endl;
if (QDate::fromString(aux1, "yyyyMMdd").isValid()){
qso = "<QSO_DATE:" + QString::number(aux1.length()) + ">" + aux1 + " ";
}
else {
//qDebug() << "eLogClubLog::getClubLogAdif: END error " << endl;
return QString();
}
//qso = "<QSO_DATE:" + QString::number((_q.at(0)).length()) + ">" + _q.at(0) + " ";
qso = qso + "<TIME_ON:" + QString::number((_q.at(1)).length()) + ">" + _q.at(1) + " ";
//qDebug() << "eLogClubLog::getClubLogAdif: 10" << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: 10" << endl;
if ((_q.at(2)).length()>0)
{
qso = qso + "<QSLRDATE:" + QString::number((_q.at(2)).length()) + ">" + _q.at(2) + " ";
}
//qDebug() << "eLogClubLog::getClubLogAdif: 20" << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: 20" << endl;
if ((_q.at(3)).length()>0)
{
qso = qso + "<QSLSDATE:" + QString::number((_q.at(3)).length()) + ">" + _q.at(3) + " ";
}
//qDebug() << "eLogClubLog::getClubLogAdif: 30" << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: 30" << endl;
qso = qso + "<CALL:" + QString::number((_q.at(4)).length()) + ">" + _q.at(4) + " ";
//qDebug() << "eLogClubLog::getClubLogAdif: 40" << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: 40" << endl;
if ((_q.at(5)).length()>0)
{
qso = qso + "<OPERATOR:" + QString::number((_q.at(5)).length()) + ">" + _q.at(5) + " ";
}
//qDebug() << "eLogClubLog::getClubLogAdif: 50" << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: 50" << endl;
qso = qso + "<MODE:" + QString::number((_q.at(6)).length()) + ">" + _q.at(6) + " ";
//qDebug() << "eLogClubLog::getClubLogAdif: 60" << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: 60" << endl;
qso = qso + "<BAND:" + QString::number((_q.at(7)).length()) + ">" + _q.at(7) + " ";
//qDebug() << "eLogClubLog::getClubLogAdif: 70" << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: 70" << endl;
if ((_q.at(8)).length()> 2)
{
qso = qso + "<BAND_RX:" + QString::number((_q.at(8)).length()) + ">" + _q.at(8) + " ";
@ -442,41 +451,41 @@ NOTES
}
//qDebug() << "eLogClubLog::getClubLogAdif: 90" << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: 90" << endl;
qso = qso + "<QSL_RCVD:" + QString::number((_q.at(10)).length()) + ">" + _q.at(10) + " ";
//qDebug() << "eLogClubLog::getClubLogAdif: 100" << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: 100" << endl;
qso = qso + "<LOTW_QSL_RCVD:" + QString::number((_q.at(11)).length()) + ">" + _q.at(11) + " ";
//qDebug() << "eLogClubLog::getClubLogAdif: 110" << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: 110" << endl;
//qso = qso + "<QSL_SENT:" + QString::number((_q.at(12)).length()) + ">" + _q.at(12) + " ";
//qDebug() << "eLogClubLog::getClubLogAdif: 120" << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: 120" << endl;
if ((_q.at(13)).toInt()> 0)
{
qso = qso + "<DXCC:" + QString::number((_q.at(13)).length()) + ">" + _q.at(13) + " ";
}
//qDebug() << "eLogClubLog::getClubLogAdif: 130'" << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: 130'" << endl;
if ((_q.at(14)).toInt()> 0)
{
qso = qso + "<PROP_MODE:" + QString::number((_q.at(14)).length()) + ">" + _q.at(14) + " ";
}
//qDebug() << "eLogClubLog::getClubLogAdif: 140" << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: 140" << endl;
if ((_q.at(15)).length()>0)
{
qso = qso + "<CREDIT_GRANTED:" + QString::number((_q.at(15)).length()) + ">" + _q.at(15) + " ";
}
//qDebug() << "eLogClubLog::getClubLogAdif: 150" << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: 150" << endl;
qso = qso + "<EOR>";
//qDebug() << "eLogClubLog:: - QSO: " << qso << endl;
//qDebug() << "eLogClubLog::getClubLogAdif: 100" << endl;
//qDebug()<< "eLogClubLog:: - QSO: " << qso << endl;
//qDebug()<< "eLogClubLog::getClubLogAdif: 100" << endl;
return qso;
}
void eLogClubLog::setCredentials(const QString &_email, const QString &_pass, const QString _defaultStationCallsign)
{
//qDebug() << "eLogClubLog::setCredentials: email: " << _email << " / Pass: " << _pass << " / StationCallsign: " << _defaultStationCallsign << endl;
//qDebug()<< "eLogClubLog::setCredentials: email: " << _email << " / Pass: " << _pass << " / StationCallsign: " << _defaultStationCallsign << endl;
stationCallsign = _defaultStationCallsign;
email = _email;
pass = _pass;
@ -486,10 +495,10 @@ void eLogClubLog::setCredentials(const QString &_email, const QString &_pass, co
int eLogClubLog::deleteQSO(QStringList _qso)
{
//qDebug() << "eLogClubLog::deleteQSO: length = " << QString::number(_qso.length()) << endl;
//qDebug() << "eLogClubLog::deleteQSO: " << email << "/" << pass << "/" << api << endl;
//qDebug() << "eLogClubLog::deleteQSO: email = " << email << endl;
//qDebug() << "eLogClubLog::deleteQSO: Pass = " << pass << endl;
//qDebug()<< "eLogClubLog::deleteQSO: length = " << QString::number(_qso.length()) << endl;
//qDebug()<< "eLogClubLog::deleteQSO: " << email << "/" << pass << "/" << api << endl;
//qDebug()<< "eLogClubLog::deleteQSO: email = " << email << endl;
//qDebug()<< "eLogClubLog::deleteQSO: Pass = " << pass << endl;
// email, password, callsign, dxcall, datetime (sqlite format, not ADIF), bandid (only the number, not ADIF), api
if (_qso.length()!=18)
@ -498,7 +507,7 @@ int eLogClubLog::deleteQSO(QStringList _qso)
}
for (int i = 0; i<_qso.length(); i++)
{
//qDebug() << QString("eLogClubLog::deleteQSO: qso.at(%1) = %2").arg(i).arg(_qso.at(i)) << endl;
//qDebug()<< QString("eLogClubLog::deleteQSO: qso.at(%1) = %2").arg(i).arg(_qso.at(i)) << endl;
}
QString dxcall, sdateTime, bandid;
@ -520,9 +529,18 @@ int eLogClubLog::deleteQSO(QStringList _qso)
}
sdateTime = dateTime.toString("yyyy-MM-dd HH:mm:ss");
//qDebug() << QString("eLogClubLog::deleteQSO: DateTime = %1").arg(sdateTime) << endl;
//qDebug()<< QString("eLogClubLog::deleteQSO: DateTime = %1").arg(sdateTime) << endl;
//qDebug()<< QString("eLogClubLog::deleteQSO: band-1: ") << _qso.at(8) << endl;
bandid = (_qso.at(8)).chopped(1);
//qDebug() << QString("eLogClubLog::deleteQSO: bandid = %1").arg(bandid) << endl;
//qDebug()<< QString("eLogClubLog::deleteQSO: band-2: ") << bandid << endl;
bool ok;
int a = bandid.toInt(&ok);
if (!ok)
{ // This check is to capture potential QSOs in 222Mhz (AKA 1.25)
bandid = bandid.chopped(1);
//qDebug()<< QString("eLogClubLog::deleteQSO: band-3: ") << bandid << endl;
}
//qDebug()<< QString("eLogClubLog::deleteQSO: bandid = %1").arg(bandid) << endl;
if (bandid.toInt()<=0)
{
return -2;
@ -537,12 +555,11 @@ int eLogClubLog::deleteQSO(QStringList _qso)
//return sendData(qso);
}
QString eLogClubLog::prepareToTranslate(const QString &_m)
{
//qDebug() << "eLogClubLog:: = prepareToTranslate" << _m << endl;
//qDebug()<< "eLogClubLog:: = prepareToTranslate" << _m << endl;
if (_m == "Callsign missing")
{
return tr("Callsign missing");
@ -648,7 +665,7 @@ QString eLogClubLog::prepareToTranslate(const QString &_m)
int eLogClubLog::modifyQSO (QStringList _oldQSO, QStringList _newQSO)
{
//qDebug() << QString("eLogClubLog::modifyQSO") << endl;
//qDebug()<< QString("eLogClubLog::modifyQSO") << endl;
int x = -1;
x = deleteQSO(_oldQSO);
@ -656,9 +673,9 @@ int eLogClubLog::modifyQSO (QStringList _oldQSO, QStringList _newQSO)
return x;
}
void eLogClubLog::sendLogFile(const QString &_file, QList<int> _qso)
void eLogClubLog::sendLogFile(const QString &_file, QList<int> _qso, bool _overwrite)
{
//qDebug() << "eLogClubLog::sendLogFile: " << _file << endl;
//qDebug()<< "eLogClubLog::sendLogFile: " << _file << endl;
qsos.clear();
qsos.append(_qso);
QUrl serviceUrl;
@ -674,7 +691,7 @@ void eLogClubLog::sendLogFile(const QString &_file, QList<int> _qso)
QByteArray blob;
//QFile *file = new QFile("_file");
QFile *file = new QFile("C:/Users/radio/klog/klog-clublog-upload.adi");
QFile *file = new QFile(util->getClubLogFile());
if (file->open(QIODevice::ReadOnly))
{
blob = file->readAll();
@ -682,15 +699,15 @@ void eLogClubLog::sendLogFile(const QString &_file, QList<int> _qso)
}
else
{
//qDebug() << "eLogClubLog::sendLogFile: ERROR File not opened" << endl;
//qDebug()<< "eLogClubLog::sendLogFile: ERROR File not opened" << endl;
return;
}
file->close();
// The rest of the form goes as usual
//qDebug() << "eLogClubLog::sendLogFile: email: " << email << endl;
//qDebug() << "eLogClubLog::sendLogFile: pass: " << pass << endl;
//qDebug() << "eLogClubLog::sendLogFile: stationcall: " << stationCallsign << endl;
//qDebug() << "eLogClubLog::sendLogFile: api: " << api << endl;
//qDebug()<< "eLogClubLog::sendLogFile: email: " << email << endl;
//qDebug()<< "eLogClubLog::sendLogFile: pass: " << pass << endl;
//qDebug()<< "eLogClubLog::sendLogFile: stationcall: " << stationCallsign << endl;
//qDebug()<< "eLogClubLog::sendLogFile: api: " << api << endl;
QHttpPart emailPart;
emailPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"email\""));
@ -707,16 +724,24 @@ void eLogClubLog::sendLogFile(const QString &_file, QList<int> _qso)
QHttpPart apiPart;
apiPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"api\""));
apiPart.setBody(api.toUtf8());
QString one = QString("1");
QString one;
if (_overwrite)
{
one = QString("1");
}
else
{
one = QString("0");
}
//QString one = QString("1");
QHttpPart clearPart;
clearPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"clear\""));
clearPart.setBody(one.toUtf8());
QHttpPart filePart;
QString aux = QString("form-data; name=\"file\"; filename=\"%1\"").arg(_file);
filePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/octet-stream"));
filePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"file\"; filename=\"klog-clublog-upload.adi\""));
filePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(aux));
filePart.setBody(blob);
multiPart->append(filePart);
@ -732,7 +757,7 @@ void eLogClubLog::sendLogFile(const QString &_file, QList<int> _qso)
manager->post(request, multiPart);
//multiPart->setParent(reply);
//qDebug() << "eLogClubLog::sendLogFile - END" << endl;
//qDebug()<< "eLogClubLog::sendLogFile - END" << endl;
}

View File

@ -32,10 +32,10 @@
#include <QProgressDialog>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#include <QUrlQuery>
#include <QHttpMultiPart>
#include <QHttpPart>
#include "utilities.h"
class eLogClubLog : public QObject {
Q_OBJECT
@ -49,12 +49,12 @@ public:
//int deleteQSOid(const int _qsoId);
int modifyQSO (QStringList _oldQSO, QStringList _newQSO);
void sendLogFile(const QString &_file, QList<int> _qso);
void sendLogFile(const QString &_file, QList<int> _qso, bool _overwrite);
private:
QString getClubLogAdif(const QStringList _q);
int sendData(const QString &_clublogCall, const QString &_q); // Sends the data (http post) to ClubLog
//int sendData(const QString &_clublogCall, const QString &_q); // Sends the data (http post) to ClubLog
int sendDataParams(const QString &_clublogCall, const QUrlQuery &_params, bool _adding);
QString prepareToTranslate(const QString &_m); // Get the message and put it in a tr to be able to translate it
@ -64,10 +64,11 @@ private:
QNetworkAccessManager *manager;
QNetworkReply* reply;
int currentQSO;
int result;
QNetworkReply::NetworkError result;
QString target;
bool uploadingFile;
QList<int> qsos;
Utilities *util;
//bool useQSOStationCallsign;
private slots:
@ -84,7 +85,7 @@ signals:
void actionError(const int _i);
void showMessage(const QString _t);
void disableClubLogAction(const bool _b);
void signalFileUploaded(int _code, QList<int>);
void signalFileUploaded(QNetworkReply::NetworkError, QList<int>);
};
#endif // DOWNLOADCTY_H

View File

@ -5,508 +5,342 @@
#include <QFile>
//#include <QDebug>
eQSLUtilities::eQSLUtilities(const QString &_klogDir, const QString &_klogVersion, const QString &_parentFunction, DataProxy_SQLite *dp)
eQSLUtilities::eQSLUtilities(const QString &_parentFunction)
{
//qDebug() << "eQSLUtilities::eQSLUtilities(): " << _klogDir << endl;
dataProxy = dp;
util = new Utilities;
//qDebug()<< "eQSLUtilities::eQSLUtilities" << endl;
user = QString();
pass = QString();
qsos.clear();
currentQSO = -1;
manager = new QNetworkAccessManager(this);
reply = nullptr;
file = new QFile;
//url = new QUrl;
klogDir = _klogDir;
klogVersion = _klogVersion;
downloadAborted = false;
stationCallsign.clear();
startDate.clear();
eqslQuery.clear();
eqslUser.clear();
eqslPassword.clear();
fileName = "lotwDownload.adi";
pDialog = new QProgressDialog(nullptr);
pDialog->cancel();
//qDebug() << "eQSLUtilities::eQSLUtilities(): - END" << endl;
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotQsoUploadFinished(QNetworkReply*)));
stationCallsign = QString();
uploadingFile = false;
util = new Utilities;
//qDebug()<< "eQSLUtilities::eQSLUtilities - END" << endl;
}
eQSLUtilities::~eQSLUtilities()
{
//qDebug() << "eQSLUtilities::~eQSLUtilities" << endl;
}
void eQSLUtilities::setFileName(const QString &_fn)
{
//qDebug() << "eQSLUtilities::setFileName: " << _fn << endl;
if (_fn.length()>0)
{
fileName = _fn;
}
//qDebug() << "eQSLUtilities::setFileName - END" << endl;
}
QString eQSLUtilities::getFileName()
{
//qDebug() << "eQSLUtilities::getFileName: " << fileName << endl;
return fileName;
}
bool eQSLUtilities::selectQuery(const int _queryId)
{
//qDebug() << "eQSLUtilities::selectQuery: - Start: " << QString::number(_queryId) << endl;
bool savePassword = true;
if (eqslPassword.length()<1)
{
savePassword = false;
bool ok;
eqslPassword = QInputDialog::getText(nullptr, tr("KLog - LoTW password needed"),
tr("Please enter your LoTW password: "), QLineEdit::Password, "", &ok);
if (!ok)
{
//qDebug() << "eQSLUtilities::selectQuery: - END 1" << endl;
return false;
}
}
eqslQuery = QString("https://lotw.arrl.org/eqsluser/lotwreport.adi?login=%1&password=%2&qso_query=1&qso_qsl=no&qso_owncall=%3&qso_startdate=%4").arg(eqslUser).arg(eqslPassword).arg(stationCallsign).arg(startDate);
if (!savePassword)
{// We delete the password as soon as possible if the user is not willing to save it
eqslPassword = QString();
}
url = QUrl(eqslQuery);
//qDebug() << "eQSLUtilities::selectQuery: - END" << endl;
return true;
}
bool eQSLUtilities::setStationCallSign (const QString &_call)
{
//qDebug() << "eQSLUtilities::setStationCallSign: " << _call << endl;
if (!util->isValidCall(_call))
{
//qDebug() << "eQSLUtilities::setStationCallSign: FALSE " << endl;
return false;
}
if (((dataProxy->getStationCallSignsFromLog(-1)).contains(_call)))
{
//qDebug() << "eQSLUtilities::setStationCallSign: TRUE" << endl;
stationCallsign = _call;
QDate date = dataProxy->getFirstQSODateFromCall(stationCallsign);
//qDebug() << "eQSLUtilities::setStationCallSign: Date: " << startDate << endl;
if (date.isValid())
{
startDate = date.toString("yyyyMMdd");
//qDebug() << "eQSLUtilities::setStationCallSign: StartDate" << startDate << endl;
}
else
{
startDate.clear();
//qDebug() << "eQSLUtilities::setStationCallSign: StartDate not valid Date" << endl;
return false;
}
//qDebug() << "eQSLUtilities::setStationCallSign: startDate: " << startDate << endl;
return true;
}
else if (dataProxy->getHowManyQSOInLog(-1) <1)
{
//qDebug() << "eQSLUtilities::setStationCallSign:TRUE Empty log" << endl;
stationCallsign = _call;
return true;
}
//qDebug() << "eQSLUtilities::setStationCallSign: FALSE 2" << endl;
return false;
}
void eQSLUtilities::startRequest(QUrl url)
{
//qDebug() << "eQSLUtilities::startRequest: " << url.toString() << endl;
QByteArray agent = QString("KLog-" + klogVersion).toUtf8();
QNetworkRequest request;
request.setUrl(url);
request.setHeader(QNetworkRequest::UserAgentHeader, agent);
//request.setRawHeader("User-Agent", agent);
//reply = manager->get(QNetworkRequest(url));
reply = manager->get(request);
//qDebug() << "eQSLUtilities::startRequest - 10" << endl;
// Whenever more data is received from the network,
// this readyRead() signal is emitted
connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
// Also, downloadProgress() signal is emitted when data is received
connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(slotDownloadProgress(qint64)));
// This signal is emitted when the reply has finished processing.
// After this signal is emitted,
// there will be no more updates to the reply's data or metadata.
connect(reply, SIGNAL(finished()), this, SLOT(slotFinished()));
//qDebug() << "eQSLUtilities::startRequest: - END" << endl;
}
int eQSLUtilities::download()
{
//qDebug() << "eQSLUtilities::download - Start" << endl;
if (!selectQuery(-1))
{
//qDebug() << "eQSLUtilities::download - END-1" << endl;
return -1;
}
//qDebug() << "eQSLUtilities::download: - 10" << endl;
QFileInfo fileInfo(url.path());
//qDebug() << "eQSLUtilities::download: - 11" << endl;
if (QFile::exists(fileName))
{
//qDebug() << "eQSLUtilities::download: - 12" << endl;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - File exist"));
QString aux = QString(tr("There is a file already existing with the name that will be used.") );
msgBox.setText(tr("The file %1 already exist. Do you want to overwrite?").arg(fileName));
msgBox.setDetailedText(aux);
msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
//qDebug() << "eQSLUtilities::download: - 13" << endl;
if (ret == QMessageBox::No)
{
//qDebug() << "eQSLUtilities::download - END- 2" << endl;
return -2;
}
//qDebug() << "eQSLUtilities::download: - 14" << endl;
//file->close();
//file->remove(fileName);
//QFile::remove(fileName);
//qDebug() << "eQSLUtilities::download: - 15" << endl;
}
//qDebug() << "eQSLUtilities::download: - 20 Filename: -" << fileName << "-" << endl;
if (!file->isOpen())
{
//qDebug() << "eQSLUtilities::download: - 21 Filename: -" << endl;
file->setFileName(fileName);
//qDebug() << "eQSLUtilities::download: - 22 Filename: -" << endl;
}
//qDebug() << "eQSLUtilities::download: - 23 Filename: -" << endl;
if (!file->open(QIODevice::WriteOnly))
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - Can't write the file"));
QString aux = QString(tr("KLog was not able to save the file %1.\nError returned: %2") ).arg(fileName).arg(file->errorString());
msgBox.setText(tr("The file %1 already exists.").arg(fileName));
msgBox.setDetailedText(aux);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
//file->close();
//delete file;
//file = nullptr;
//qDebug() << "eQSLUtilities::download - END - 3" << endl;
return -3;
}
//qDebug() << "eQSLUtilities::download: - 30" << endl;
// used for progressDialog
// This will be set true when canceled from progress dialog
downloadAborted = false;
//qDebug() << "eQSLUtilities::download: - 31" << endl;
//progressDialog = new QProgressDialog(nullptr);
//qDebug() << "eQSLUtilities::download: - 40" << endl;
pDialog->setLabelText(tr("Downloading data to file: %1.").arg(fileName));
//qDebug() << "eQSLUtilities::download: - 41" << endl;
pDialog->setWindowTitle(tr("KLog - LoTW download"));
//qDebug() << "eQSLUtilities::download: - 42" << endl;
pDialog->setWindowModality(Qt::WindowModal);
//qDebug() << "eQSLUtilities::download: - 43" << endl;
pDialog->reset();
//qDebug() << "eQSLUtilities::download: - 44" << endl;
pDialog->setRange(0, 0);
//qDebug() << "eQSLUtilities::download: - 45" << endl;
pDialog->setMinimumDuration(0);
//qDebug() << "eQSLUtilities::download: - 46" << endl;
pDialog->show();
//qDebug() << "eQSLUtilities::download: - 47" << endl;
connect(pDialog, SIGNAL(canceled()), this, SLOT(slotCancelDownload()));
//qDebug() << "eQSLUtilities::download: - 50" << endl;
startRequest(url);
//qDebug() << "eQSLUtilities::download - END" << endl;
return 1;
}
void eQSLUtilities::slotDownloadProgress(qint64 bytesRead) {
//qDebug() << "eQSLUtilities::slotDownloadProgress: " << QString::number(bytesRead) << "/" << QString::number(totalBytes) << endl;
if (downloadAborted)
{
//qDebug() << "eQSLUtilities::slotDownloadProgress: CANCELLED" << endl;
return;
}
pDialog->setValue(bytesRead);
//qDebug() << "eQSLUtilities::slotDownloadProgress - END " << endl;
}
void eQSLUtilities::slotReadyRead()
{
//qDebug() << "eQSLUtilities::slotReadyRead: " << reply->readLine() << endl;
if (file)
{
file->write(reply->readAll());
}
//qDebug() << "eQSLUtilities::slotReadyRead - END" << endl;
}
void eQSLUtilities::slotFinished()
{
//qDebug() << "eQSLUtilities::slotFinished - Started" << endl;
// when canceled
if (downloadAborted)
{
if (file)
{
file->close();
file->remove();
//delete file;
//file = nullptr;
}
//reply->deleteLater();
pDialog->cancel();
reply->close();
//qDebug() << "eQSLUtilities::slotFinished - END Canceled" << endl;
return;
}
// download finished normally
pDialog->cancel();
file->flush();
file->close();
// get redirection url
QVariant redirectionTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
if (reply->error())
{
file->remove();
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - Download error"));
QString aux = QString(tr("The downloading error is: %1") ).arg(reply->errorString());
msgBox.setText(tr("There was an error while downloading the file from LoTW."));
msgBox.setDetailedText(aux);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
else if (!redirectionTarget.isNull())
{
QUrl newUrl = url.resolved(redirectionTarget.toUrl());
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - Redirection found"));
QString aux = QString(tr("The remote server redirected our connection to %1") ).arg(newUrl.toString());
msgBox.setText(tr("Do you want to follow the redirection?"));
msgBox.setDetailedText(aux);
msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
{
url = newUrl;
//reply->deleteLater();
file->open(QIODevice::WriteOnly);
file->resize(0);
startRequest(url);
//qDebug() << "eQSLUtilities::slotFinished - END-1" << endl;
return;
}
}
else
{
//QString fileName = QFileInfo(QUrl(ui->urlEdit->text()).path()).fileName();
//ui->statusLabel->setText(tr("Downloaded %1 to %2.").arg(fileName).arg(QDir::currentPath()));
//ui->downloadButton->setEnabled(true);
//qDebug() << "eQSLUtilities::slotFinished: " << endl;
}
//reply->deleteLater();
parseDownloadedFile(file->fileName());
//delete file;
//file = nullptr;
//qDebug() << "eQSLUtilities::slotReadyRead - END" << endl;
}
void eQSLUtilities::slotCancelDownload()
{
//qDebug() << "eQSLUtilities::slotCancelDownload - Start" << endl;
downloadAborted = true;
reply->abort();
//qDebug() << "eQSLUtilities::slotCancelDownload - END" << endl;
//qDebug()<< "eQSLUtilities::~eQSLUtilities" << endl;
}
void eQSLUtilities::setUser(const QString &_call)
{
//qDebug() << "eQSLUtilities::setUser: " << _call << endl;
eqslUser = _call;
user = _call;
//qDebug() << "eQSLUtilities::setUser: END" << endl;
}
void eQSLUtilities::setPass(const QString &_pass)
{
//qDebug() << "eQSLUtilities::setPass: " << _pass << endl;
eqslPassword = _pass;
pass = _pass;
//qDebug() << "eQSLUtilities::setPass: END" << endl;
}
bool eQSLUtilities::getIsReady()
void eQSLUtilities::slotQsoUploadFinished(QNetworkReply *data)
{
//qDebug() << "eQSLUtilities::getIsReady: user/station: -" << eqslUser <<"/" << stationCallsign << "-" << endl;
if ((eqslUser.length()>1) && (stationCallsign.length()>1))
//qDebug()<< "eQSLUtilities::slotQsoUploadFinished" << endl;
result = data->error();
//qDebug()<< "eQSLUtilities::slotQsoUploadFinished - Result = " << QString::number(result) << endl;
const QByteArray sdata = data->readAll();
QString text = QString();
if (currentQSO>0)
{
//qDebug() << "eQSLUtilities::getIsReady: true" << endl;
return true;
emit actionReturnDownload(result, currentQSO);
currentQSO = -1;
}
if (result == QNetworkReply::NoError)
{
text = "eQSL: " + prepareToTranslate(sdata);
//qDebug()<< sdata;
//qDebug()<< "eQSLUtilities::slotQsoUploadFinished - NO ERROR" << endl;
if (uploadingFile)
{
uploadingFile = false;
emit signalFileUploaded(QNetworkReply::NoError, qsos);
qsos.clear();
return;
}
}
else if (result == QNetworkReply::HostNotFoundError)
{
//qDebug()<< "eQSLUtilities::slotQsoUploadFinished - Result = Host Not found! = " << QString::number(result) << endl;
text = "eQSL: " + tr("Host not found!");
//TODO: Mark the previous QSO as not sent to clublog
}
else if (result == QNetworkReply::TimeoutError)
{
//qDebug()<< "eQSLUtilities::slotQsoUploadFinished - Result = Time out error! = " << QString::number(result) << endl;
text = "eQSL: " + tr("Timeout error!");
//TODO: Mark the previous QSO as not sent to clublog
}
else
{
//qDebug() << "eQSLUtilities::getIsReady: false" << endl;
return false;
//qDebug()<< "eQSLUtilities::slotQsoUploadFinished - Result = UNDEFINED = " << QString::number(result) << endl;
text = "eQSL: " + tr("Undefined error number (#%1)... ").arg(result);
int i = QMessageBox::warning(nullptr, tr("KLog - eQSL"),
tr("We have received an undefined error from eQSL (%1)").arg(result) + "\n" +
tr("Please check your config in the setup and contact the KLog development team if you can't fix it. eQSL uploads will be disabled."),
QMessageBox::Ok);
//TODO: Mark the previous QSO as not sent to clublog
}
//qDebug()<< "eQSLUtilities::slotQsoUploadFinished - Result = " << QString::number(result) << endl;
//emit done();
emit signalFileUploaded(result, qsos);
emit showMessage(text);
}
void eQSLUtilities::parseDownloadedFile(const QString &_fn)
void eQSLUtilities::slotFileUploadFinished(QNetworkReply *data)
{
//qDebug() << "eQSLUtilities::parseDownloadedFile: " << _fn << endl;
QString _fileName = _fn;
QMessageBox msgBox;
QString aux;
//qDebug()<< "eQSLUtilities::slotFileUploadFinished" << endl;
QFile file( _fileName );
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
result = data->error();
//qDebug()<< "eQSLUtilities::slotFileUploadFinished - Result = " << QString::number(result) << endl;
const QByteArray sdata = data->readAll();
QString text = QString();
if (result == QNetworkReply::NoError)
{
//qDebug() << "eQSLUtilities::parseDownloadedFile File not found" << _fileName << endl;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - File not found"));
msgBox.setText(tr("KLog can't find the downloaded file."));
aux = QString(tr("It was not possible for find the file %1 that has been just downloaded.") ).arg(_fn);
msgBox.setDetailedText(aux);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
//qDebug() << "eQSLUtilities::parseDownloadedFile: END-1" << endl;
return ;
text = "eQSL: " + prepareToTranslate(sdata);
//qDebug()<< "eQSLUtilities::slotFileUploadFinished - Result = NoError = " << QString::number(result) << endl;
//qDebug()<< sdata;
}
else if (result == QNetworkReply::HostNotFoundError)
{
//qDebug()<< "eQSLUtilities::slotFileUploadFinished - Result = Host Not found! = " << QString::number(result) << endl;
text = "eQSL: " + tr("Host not found!");
}
else if (result == QNetworkReply::TimeoutError)
{
//qDebug()<< "eQSLUtilities::slotFileUploadFinished - Result = Time out error! = " << QString::number(result) << endl;
text = "eQSL: " + tr("Timeout error!");
}
else
{
//qint64 startOfFile = file.pos();
// Look for a Header
bool hasHeader = false;
int numQSO = 0;
QString Lotw_owncall = QString("OWNCALL: %1").arg(stationCallsign.toUpper());
//bool hasOwnCall = false;
//bool hasProgramID = false;
bool userPasswordError = false;
while ((!file.atEnd()) && (!hasHeader))
{
QByteArray line = file.readLine();
QString lineU = line.toUpper();
//qDebug() << "eQSLUtilities::parseDownloadedFile: lineU: " << lineU << endl;
if (lineU.contains("<EOH>"))
{
//qDebug() << "eQSLUtilities::parseDownloadedFile: EOH found" << endl;
hasHeader = true;
}
//else if (lineU.contains("<PROGRAMID:4>LOTW"))
//{
// //qDebug() << "eQSLUtilities::parseDownloadedFile: ProgramID found" << endl;
// hasProgramID = true;
//}
//else if (lineU.contains(Lotw_owncall))
//{
// //qDebug() << "eQSLUtilities::parseDownloadedFile: OWNCALL found" << endl;
// hasOwnCall = true;
//}
else if (lineU.contains("<APP_LOTW_NUMREC:"))
{
QStringList data;
data << lineU.split('>', QString::SkipEmptyParts);
numQSO = (data.at(1)).toInt();
//qDebug() << "eQSLUtilities::parseDownloadedFile: QSOs: " << QString::number(numQSO) << endl;
}
else if (lineU.contains("<I>USERNAME/PASSWORD INCORRECT</I>"))
{
userPasswordError = true;
}
}
// WE HAVE JUST FINISHED TO READ THE HEADER OR THE FILE, IF IT IS NOT AN ADIF
if (!hasHeader || (numQSO<1))
{
//qDebug() << "eQSLUtilities::parseDownloadedFile Header not found" << _fileName << endl;
QString aux;
if (userPasswordError)
{
msgBox.setWindowTitle(tr("KLog - LoTW user/password error"));
msgBox.setText(tr("LoTW server did not recognized your user/password"));
aux = QString(tr("Check your user and password and ensure your are using the right one before trying again.") );
}
else if(numQSO<1)
{
msgBox.setWindowTitle(tr("KLog - LoTW No QSOs "));
msgBox.setText(tr("LoTW sent no QSOs"));
aux = QString(tr("It seems that LoTW has no QSO with the Station Callsign you are using (%1).") ).arg(stationCallsign);
}
else
{
msgBox.setWindowTitle(tr("KLog - LoTW Unknown error"));
msgBox.setText(tr("KLog can't recognize the file that has been downloaded from LoTW."));
aux = QString(tr("Try again and send the downloaded file (%1) to the KLog developer for analysis.") ).arg(_fileName);
}
msgBox.setIcon(QMessageBox::Warning);
msgBox.setDetailedText(aux);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
//qDebug() << "eQSLUtilities::parseDownloadedFile: END-2" << endl;
file.remove();
return ;
}
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(tr("KLog - LoTW download"));
msgBox.setText(tr("KLog downloaded %1 QSOs successfully. Do you want to update your log with the downloaded data?").arg(QString::number(numQSO)));
aux = QString(tr("Now KLog will process the downloaded QSO and update your local log.") );
msgBox.setDetailedText(aux);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
if (msgBox.exec() == QMessageBox::No)
{
//qDebug() << "eQSLUtilities::parseDownloadedFile: END-2" << endl;
return ;
}
//file.seek(startOfFile);
emit actionProcessLoTWDownloadedFile(_fileName);
//qDebug()<< "eQSLUtilities::slotFileUploadFinished - Result = UNDEFINED = " << QString::number(result) << endl;
text = "eQSL: " + tr("Undefined error...");
}
//Procesar los QSOs y meterlos en una tabla? o en un QStringList o alguna otra estructura
//qDebug() << "eQSLUtilities::parseDownloadedFile - END" << endl;
//qDebug()<< "eQSLUtilities::slotFileUploadFinished - Result = " << QString::number(result) << endl;
//emit done();
emit showMessage(text);
}
/*void eQSLUtilities::showMessage(const int _messageIcon, const QString &_msg, const QString &_msgExt)
void eQSLUtilities::downloadProgress(qint64 received, qint64 total) {
//qDebug()<< "eQSLUtilities::downloadProgress: " << QString::number(received) << "/" << QString::number(total) << endl;
//qDebug()<< received << total;
emit actionShowProgres(received, total);
}
void eQSLUtilities::slotErrorManagement(QNetworkReply::NetworkError networkError)
{
//qDebug()<< "eQSLUtilities::slotErrorManagement: " << QString::number(networkError) << endl;
result = networkError;
if (result == QNetworkReply::NoError)
{
}
else if (result == QNetworkReply::HostNotFoundError)
{
//qDebug()<< "eQSLUtilities::slotErrorManagement: Host not found" << endl;
}
else
{
//qDebug()<< "eQSLUtilities::slotErrorManagement: ERROR!" << endl;
}
//actionError(result);
}
void eQSLUtilities::setCredentials(const QString &_user, const QString &_pass, const QString _defaultStationCallsign)
{
//qDebug()<< "eQSLUtilities::setCredentials: user: " << _user << " / Pass: " << _pass << " / StationCallsign: " << _defaultStationCallsign << endl;
stationCallsign = _defaultStationCallsign;
user = _user;
pass = _pass;
}
QString eQSLUtilities::prepareToTranslate(const QString &_m)
{
//qDebug()<< "eQSLUtilities:: = prepareToTranslate" << _m << endl;
if (_m == "Callsign missing")
{
return tr("Callsign missing");
}
else if (_m == "Invalid callsign")
{
return tr("Invalid callsign");
}
else if (_m == "Skipping SWL callsign")
{
return tr("Skipping SWL callsign");
}
else if (_m == "Callsign is your own call")
{
return tr("Callsign is your own call");
}
else if (_m == "Invalid callsign with no DXCC mapping")
{
return tr("Invalid callsign with no DXCC mapping");
}
else if (_m == "Updated QSO")
{
return tr("Updated QSO");
}
else if (_m == "Invalid ADIF record")
{
return tr("Invalid ADIF record");
}
else if (_m == "Missing ADIF record")
{
return tr("Missing ADIF record");
}
else if (_m == "Test mode - parameters ok, no action taken")
{
return tr("Test mode - parameters ok, no action taken");
}
else if (_m == "Excessive API Usage")
{
return tr("Excessive API Usage");
}
else if (_m == "Internal Error")
{
return tr("Internal Error");
}
else if (_m == "Rejected")
{
return tr("Rejected");
}
else if (_m == "QSO Duplicate")
{
return tr("QSO Duplicate");
}
else if (_m == "QSO Modified")
{
return tr("QSO Modified");
}
else if (_m == "Missing Login")
{
return tr("Missing Login");
}
else if (_m == "QSO OK")
{
return tr("QSO OK");
}
else if (_m == "Upload denied")
{
return tr("Upload denied");
}
else if (_m == "No callsign selected")
{
return tr("No callsign selected");
}
else if (_m == "No match found")
{
return tr("No match found");
}
else if (_m == "Dropped QSO")
{
return tr("Dropped QSO");
}
else if (_m == "OK")
{
return tr("OK");
}
else if (_m == "Login rejected")
{
return tr("Login rejected");
}
else if (_m == "Upload denied")
{
return tr("Upload denied");
}
else if (_m == "Rejected: Callsign is your own call")
{
return tr("Rejected: Callsign is your own call");
}
else
{
return _m;
}
}
void eQSLUtilities::sendLogFile(const QString &_file, QList<int> _qso)
{
//qDebug()<< "eQSLUtilities::sendLogFile: " << _file << endl;
qsos.clear();
qsos.append(_qso);
QUrl serviceUrl;
serviceUrl = QUrl("https://www.eQSL.cc/qslcard/ImportADIF.cfm");
QByteArray postData;
QUrlQuery params;
// FIRST PARAMS is the file
QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
QByteArray blob;
QFile *file = new QFile(_file);
if (file->open(QIODevice::ReadOnly))
{
blob = file->readAll();
//qDebug()<< "eQSLUtilities::sendLogFile: FILE OPEN: " << blob << endl;
}
else
{
//qDebug()<< "eQSLUtilities::sendLogFile: ERROR File not opened" << endl;
return;
}
file->close();
// The rest of the form goes as usual
//qDebug()<< "eQSLUtilities::sendLogFile: e: " << user << endl;
//qDebug()<< "eQSLUtilities::sendLogFile: pass: " << pass << endl;
//qDebug()<< "eQSLUtilities::sendLogFile: stationcall: " << stationCallsign << endl;
QHttpPart userPart;
userPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"eqsl_user\""));
userPart.setBody(user.toUtf8());
QHttpPart passPart;
passPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"eqsl_pswd\""));
passPart.setBody(pass.toUtf8());
QHttpPart filePart;
QString aux = QString("form-data; name=\"Filename\"; filename=\"%1\"").arg(_file);
filePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/octet-stream"));
filePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(aux));
filePart.setBody(blob);
multiPart->append(userPart);
multiPart->append(passPart);
multiPart->append(filePart);
uploadingFile = true;
QNetworkRequest request(serviceUrl);
manager->post(request, multiPart);
//multiPart->setParent(reply);
//qDebug()<< "eQSLUtilities::sendLogFile - END" << endl;
}
*/

View File

@ -5,7 +5,7 @@
-------------------
begin : oct 2020
copyright : (C) 2020 by Jaime Robles
email : jaime@robles.es
user : jaime@robles.es
***************************************************************************/
/*****************************************************************************
@ -22,82 +22,71 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with KLog. If not, see <https://www.gnu.org/licenses/>. *
* along with KLog. If not, see <https://www.gnu.org/licenses/>. *
* *
*****************************************************************************/
#include <QObject>
#include <QString>
#include <QProgressDialog>
#include <QFile>
#include <QFileInfo>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QSslError>
#include <QTimer>
#include <QUrl>
#include <QString>
#include <QMessageBox>
#include <QInputDialog>
#include "dataproxy_sqlite.h"
#include <QProgressDialog>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#include <QUrlQuery>
#include <QHttpMultiPart>
#include <QHttpPart>
#include "utilities.h"
class QSslError;
class eQSLUtilities : public QObject
{
class eQSLUtilities : public QObject {
Q_OBJECT
public:
explicit eQSLUtilities(const QString &_klogDir, const QString &_klogVersion, const QString &_parentFunction, DataProxy_SQLite *dp);
explicit eQSLUtilities(const QString &_parentFunction);
~eQSLUtilities();
bool setStationCallSign(const QString &_call);
int download();
void setUser(const QString &_call);
void setPass(const QString &_pass);
bool getIsReady();
void setFileName(const QString &_fn);
QString getFileName();
void setCredentials(const QString &_user, const QString &_pass, const QString _defaultStationCallsign);
//int sendQSO(QStringList _qso);
//int deleteQSO(QStringList _qso);
//int modifyQSO (QStringList _oldQSO, QStringList _newQSO);
void sendLogFile(const QString &_file, QList<int> _qso);
private:
void startRequest(QUrl url);
bool selectQuery(const int _queryId);
void parseDownloadedFile(const QString &_fn);
//void showMessage(const int _messageIcon, const QString &_msg, const QString &_msgExt);
//QString geteQSLAdif(const QStringList _q);
//int sendData(const QString &_eQSLUser, const QString &_q); // Sends the data (http post) to eQSL
//int sendDataParams(const QString &_eQSLUser, const QUrlQuery &_params);
QString prepareToTranslate(const QString &_m); // Get the message and put it in a tr to be able to translate it
Utilities *util;
//void setTarget(const QString& t);
QString user, pass, stationCallsign;
QNetworkAccessManager *manager;
QNetworkReply *reply;
QFile *file;
bool downloadAborted;
qint64 fileSize;
QUrl url;
QProgressDialog *pDialog;
QString klogDir, klogVersion;
QString urld;
QString fileName;
QString stationCallsign;
QString startDate;
QString eqslQuery;
QString eqslUser, eqslPassword;
DataProxy_SQLite *dataProxy;//, *dataProxyPrepared;
QNetworkReply* reply;
int currentQSO;
QNetworkReply::NetworkError result;
QString target;
bool uploadingFile;
QList<int> qsos;
Utilities *util;
//bool useQSOStationCallsign;
private slots:
void slotReadyRead();
void slotFinished();
void slotDownloadProgress(qint64 bytesRead);
void slotCancelDownload();
void slotQsoUploadFinished(QNetworkReply* data);
void slotFileUploadFinished(QNetworkReply* data);
void downloadProgress(qint64 received, qint64 total);
void slotErrorManagement(QNetworkReply::NetworkError networkError);
signals:
void actionProcessLoTWDownloadedFile(QString _fn);
void actionReturnDownload(const int _i, const int _qsoId);
void done();
void actionShowProgres(qint64 received, qint64 total);
void actionError(const int _i);
void showMessage(const QString _t);
void disableeQSLAction(const bool _b);
void signalFileUploaded(QNetworkReply::NetworkError, QList<int>);
};
#endif // EQSLUTILITIES_H

View File

@ -262,6 +262,12 @@ QList<int> FileManager::adifLogExportReturnList(const QString& _fileName, const
queryStringCount = QString("SELECT COUNT (id) FROM log WHERE") + _queryStation + QString(" AND clublog_qso_upload_status='M'") + _queryDateFrom + _queryDateTo;
queryString = QString("SELECT id, call, rst_sent, rst_rcvd, freq, bandid, band_rx, modeid, qso_date, qsl_rcvd, qslrdate, qslsdate, prop_mode, operator, station_callsign, dxcc, qsl_sent, lotw_qsl_rcvd, credit_granted, notes, qso_date_off FROM log WHERE") + _queryStation + QString(" AND clublog_qso_upload_status='M'") + _queryDateFrom + _queryDateTo;
}
else if (_em == ModeEQSL)
{
//qDebug() << "FileManager::adifLogExportReturnList: Exporting for eQSL" << endl;
queryStringCount = QString("SELECT COUNT (id) FROM log WHERE") + _queryStation + QString(" AND eqsl_qsl_sent='Q'") + _queryDateFrom + _queryDateTo;
queryString = QString("SELECT id, call, rst_sent, freq, bandid, modeid, qso_date, prop_mode, operator, station_callsign, sat_name, my_cnty, my_gridsquare, my_lat, my_lon FROM log WHERE") + _queryStation + QString(" AND eqsl_qsl_sent='Q'") + _queryDateFrom + _queryDateTo;
}
else
{
//qDebug() << "FileManager::adifLogExportReturnList: Exporting normal ADIF" << endl;
@ -285,7 +291,7 @@ QList<int> FileManager::adifLogExportReturnList(const QString& _fileName, const
//qDebug() << "FileManager::adifLogExportReturnList: " << query.lastQuery() << endl;
if (!sqlOK)
{
//qDebug() << "FileManager::adifLogExportReturnList: Query Error" << endl;
//qDebug() << "FileManager::adifLogExportReturnList: Query Error" << endl;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().number(), query.lastQuery());
return qsos;
}
@ -321,12 +327,25 @@ QList<int> FileManager::adifLogExportReturnList(const QString& _fileName, const
progress.setAutoClose(true);
out << "ADIF v3.1.1 Export from KLog\nhttps://www.klog.xyz/klog\n<PROGRAMVERSION:" << QString::number(klogVersion.length()) << ">" << klogVersion << "\n<PROGRAMID:4>KLOG" << endl;
out << "<APP_KLOG_QSOS:" << QString::number((QString::number(numberOfQsos)).length()) << ">" << QString::number(numberOfQsos) << endl;
writeADIFHeader(out, _em, numberOfQsos);
/*
QDateTime dateTime = (QDateTime::currentDateTime()).toUTC();
out << "<APP_KLOG_LOG_DATE_EXPORT:" << QString::number((dateTime.toString("yyyyMMdd-hhmm")).length()) << ">" << dateTime.toString("yyyyMMdd-hhmm") << endl;
out << "<EOH>" << endl;
if (_em != ModeEQSL)
{
out << "ADIF v3.1.0 Export from KLog\nhttps://www.klog.xyz/klog\n<PROGRAMVERSION:" << QString::number(klogVersion.length()) << ">" << klogVersion << "\n<PROGRAMID:4>KLOG " << endl;
out << "<APP_KLOG_QSOS:" << QString::number((QString::number(numberOfQsos)).length()) << ">" << QString::number(numberOfQsos) << endl;
out << "<APP_KLOG_LOG_DATE_EXPORT:" << QString::number((dateTime.toString("yyyyMMdd-hhmm")).length()) << ">" << dateTime.toString("yyyyMMdd-hhmm") << endl;
}
else
{
//out << "ADIF v3.1.0 Export from KLog\nhttps://www.klog.xyz/klog\n<PROGRAMVERSION:" << QString::number(klogVersion.length()) << ">" << klogVersion << "\n<PROGRAMID:4>KLOG " << endl;
out << "ADIF v3.1.0 Export from KLog\n<PROGRAMID:4>KLog " << endl;
}
*/
//out << "<EOH>" << endl;
i = 0;
@ -405,6 +424,109 @@ QList<int> FileManager::adifLogExportReturnList(const QString& _fileName, const
progress.setValue(numberOfQsos);
return qsos;
}
bool FileManager::adifQSOsExport(const QString& _fileName, QList<int> _qsos)
{
//qDebug() << "FileManager::adifQSOsExport: " << _fileName << endl;
int numberOfQSOs = _qsos.length();
if (numberOfQSOs<1)
{
//TODO: Warn the user NO QSOS TO EXPORT
//qDebug() << "FileManager::adifQSOsExport: No QSOs received to be exported" << endl;
}
//qDebug() << "FileManager::adifQSOsExport - 01" << endl;
QFile file(_fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return false;
//qDebug() << "FileManager::adifQSOsExport - 02" << endl;
QTextStream out(&file);
QSqlQuery query;
QString queryString;
queryString = QString("SELECT * FROM log WHERE id IN (");
//qDebug() << "FileManager::adifQSOsExport - 10" << endl;
QString numbers = QString();
foreach (int i, _qsos)
{
//qDebug() << "FileManager::adifQSOsExport - query: " << QString("id = '%1'").arg(i) << endl;
numbers = numbers + QString::number(i) ;
if (i != _qsos.last())
{
numbers = numbers + ", ";
}
}
queryString = queryString + numbers + ")";
//qDebug() << "FileManager::adifQSOsExport: writing the header" << endl;
writeADIFHeader(out, ModeADIF, _qsos.length());
//qDebug() << "FileManager::adifQSOsExport: writing the body" << endl;
bool sqlOK = query.exec(queryString);
if (!sqlOK)
{
//qDebug() << "FileManager::adifQSOsExport: query error: " << query.lastQuery() << endl;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().number(), query.lastQuery());
}
//qDebug() << "FileManager::adifQSOsExport: query: " << query.lastQuery() << endl;
QProgressDialog progress(tr("Writing ADIF file..."), tr("Abort writing"), 0, numberOfQSOs, this);
progress.setMaximum(numberOfQSOs);
progress.setWindowModality(Qt::ApplicationModal);
progress.setWindowTitle(tr("Export progress"));
int currentQso = 0;
int step = util->getProgresStepForDialog(numberOfQSOs);
while ( (query.next()) && (!noMoreQso) )
{
//qDebug() << "FileManager::adifLogExportToFile - Just in the While" << endl;
if (query.isValid())
{
writeQuery(query, out, ModeADIF, false, false, -1);
} // Closes the isValid
//qDebug() << "FileManager::adifLogExportToFile - before showing progress: " << QString::number(currentQso) << endl;
currentQso++;
if (( (currentQso % step )== 0) )
{ // To update the speed I will only show the progress once each X QSOs
//qDebug() << "FileManager::adifLogExportToFile - Showing progress: " << endl;
QString aux1 = tr("Writing ADIF file...\n QSO: ") + QString::number(currentQso) + "/" + QString::number(numberOfQSOs);
progress.setLabelText(aux1);
progress.setValue(currentQso);
}
//qDebug() << "FileManager::adifLogExportToFile - after showing progress (current%Step): " << QString::number(currentQso%step) << endl;
if ( progress.wasCanceled() )
{
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - User cancelled"));
QString aux = QString(tr("You have canceled the file export. The file will be removed and no data will be exported.") + "\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;
}
}
}
//qDebug() << "FileManager::adifQSOsExport - END" << endl;
return true;
}
bool FileManager::adifLogExportToFile(const QString& _fileName, const int _logN, bool justMarked, bool _qslRequested , bool _lotw)
{
@ -505,16 +627,19 @@ bool FileManager::adifLogExportToFile(const QString& _fileName, const int _logN,
//qDebug() << "FileManager::adifLogExportToFile END - Steps = " << QString::number(step) << endl;
//step = getProgresStepForDialog(numberOfQsos);
out << "ADIF v3.1.1 Export from KLog\nhttps://www.klog.xyz/klog\n<PROGRAMVERSION:" << QString::number(klogVersion.length()) << ">" << klogVersion << "\n<PROGRAMID:4>KLOG" << endl;
writeADIFHeader(out, ModeADIF, numberOfQsos);
/*
out << "ADIF v3.1.1 Export from KLog\nhttps://www.klog.xyz/klog\n<PROGRAMVERSION:" << QString::number(klogVersion.length()) << ">" << klogVersion << "\n<PROGRAMID:4>KLOG " << endl;
out << "<APP_KLOG_QSOS:" << QString::number((QString::number(numberOfQsos)).length()) << ">" << QString::number(numberOfQsos) << endl;
QDateTime dateTime = (QDateTime::currentDateTime()).toUTC();
out << "<APP_KLOG_LOG_DATE_EXPORT:" << QString::number((dateTime.toString("yyyyMMdd-hhmm")).length()) << ">" << dateTime.toString("yyyyMMdd-hhmm") << endl;
out << "<APP_KLOG_LOG_DATE_EXPORT:" << QString::number((dateTime.toString("yyyyMMdd-hhmm")).length()) << ">" << dateTime.toString("yyyyMMdd-hhmm") << endl;
out << "<EOH>" << endl;
*/
if (exportAll)
{
@ -3428,7 +3553,20 @@ bool FileManager::showInvalidCallMessage(const QString &_call){
}
}
void FileManager::writeADIFHeader(QTextStream &out, const ExportMode _em, const int _numberOfQsos)
{
if (_em == ModeEQSL)
{
out << "ADIF v3.1.0 Export from KLog\n<PROGRAMID:4>KLog " << endl;
}
else
{
out << "ADIF v3.1.0 Export from KLog\nhttps://www.klog.xyz/klog\n<PROGRAMVERSION:" << QString::number(klogVersion.length()) << ">" << klogVersion << "\n<PROGRAMID:4>KLOG " << endl;
out << "<APP_KLOG_QSOS:" << QString::number((QString::number(_numberOfQsos)).length()) << ">" << QString::number(_numberOfQsos) << endl;
out << "<APP_KLOG_LOG_DATE_EXPORT:" << QString::number((QDateTime::currentDateTime().toString("yyyyMMdd-hhmm")).length()) << ">" << QDateTime::currentDateTime().toString("yyyyMMdd-hhmm") << endl;
}
out << "<EOH>" << endl;
}
void FileManager::writeQuery(QSqlQuery query, QTextStream &out, const ExportMode _em, const bool _justMarked, const bool _onlyRequested, const int _logN )
{
@ -3486,7 +3624,17 @@ void FileManager::writeQuery(QSqlQuery query, QTextStream &out, const ExportMode
aux = util->getADIFDateFromQDateTime(tDateTime);
out << "<QSO_DATE:" << aux.length() << ">" << aux << " ";
aux = util->getADIFTimeFromQDateTime(tDateTime);
out << "<TIME_ON:" << aux.length() << ">" << aux << " ";
if (_em == ModeEQSL)
{
aux.chop(2);
out << "<TIME_ON:" << aux.length() << ">" << aux << " ";
}
else
{
out << "<TIME_ON:" << aux.length() << ">" << aux << " ";
}
}
}
@ -3521,7 +3669,11 @@ void FileManager::writeQuery(QSqlQuery query, QTextStream &out, const ExportMode
{
bandst = dataProxy->getBandNameFromFreq(freqTX);
}
out << "<FREQ:" << QString::number(aux.length()) << ">" << aux << " ";
if (_em != ModeEQSL)
{
out << "<FREQ:" << QString::number(aux.length()) << ">" << aux << " ";
}
}
if (dataProxy->getIdFromBandName(bandst)>0)
{
@ -3629,7 +3781,7 @@ void FileManager::writeQuery(QSqlQuery query, QTextStream &out, const ExportMode
}
}
nameCol = rec.indexOf("station_callsign");
if (nameCol>=0)
if ((nameCol>=0) && (_em != ModeEQSL))
{
aux = (query.value(nameCol)).toString();
//qDebug() << "FileManager::writeQuery: StationCallSign: " << aux << endl;
@ -4757,7 +4909,7 @@ void FileManager::writeQuery(QSqlQuery query, QTextStream &out, const ExportMode
}
}
out << "<EOR> " << endl;
out << "<EOR>" << endl;
}

View File

@ -71,6 +71,8 @@ public:
QList<int> adifLoTWReadLog(const QString& tfileName, const int logN);
//QList<int> adifLoTWLogExport(const QString& _fileName, const QString &_callsign, const QDate &_startDate, const QDate &_endDate, const int _logN);
//QList<int> (const QString& _fileName, const QString &_callsign, const QDate &_startDate, const QDate &_endDate, const int _logN, const bool LoTWOnly);
bool adifQSOsExport(const QString& _fileName, QList<int> _qsos);
QList<int> adifLogExportReturnList(const QString& _fileName, const QString &_callsign, const QDate &_startDate, const QDate &_endDate, const int _logN, const ExportMode _em);
bool adifLogExport(const QString& _fileName, const int _logN);
bool adifLogExportMarked(const QString& _fileName);
@ -83,6 +85,7 @@ public:
private:
bool adifLogExportToFile(const QString& _fileName, const int _logN, bool justMarked, bool _qslRequested, bool _lotw);
//bool cabrilloLogExportToFile(const QString& _fileName, const int logNconst);
//bool cabrilloLogExportCQWWToFile(const QString& _fileName, const int logNconst);
@ -110,6 +113,7 @@ private:
QString prepareStringLog();
void writeQuery(QSqlQuery query, QTextStream &out, const ExportMode _em, const bool _justMarked, const bool _onlyRequested, const int _logN);
void writeADIFHeader(QTextStream &out, const ExportMode _em, const int _numberOfQsos);
bool dbCreated;
DataBase *db;

2
klog.1
View File

@ -1,4 +1,4 @@
.TH KLog 1 "version 1.3" "Jaime Robles, EA4K" "Hamradio"
.TH KLog 1 "version 1.4" "Jaime Robles, EA4K" "Hamradio"
.SH "NAME"
klog \- The Ham Radio Logging program

View File

@ -3,8 +3,8 @@
IDI_ICON1 ICON DISCARDABLE "C:\\Users\\radio\\Desktop\\DEVEL\\klog\\trunk\\klog.ico"
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,1,0
PRODUCTVERSION 1,3,1,0
FILEVERSION 1,4,0,0
PRODUCTVERSION 1,4,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
@ -21,11 +21,11 @@ VS_VERSION_INFO VERSIONINFO
BEGIN
VALUE "CompanyName", "EA4K\0"
VALUE "FileDescription", "Hamradio logging\0"
VALUE "FileVersion", "1.3.1.0\0"
VALUE "FileVersion", "1.4.0.0\0"
VALUE "LegalCopyright", "\0"
VALUE "OriginalFilename", "klog.exe\0"
VALUE "ProductName", "klog\0"
VALUE "ProductVersion", "1.3.1.0\0"
VALUE "ProductVersion", "1.4.0.0\0"
END
END
BLOCK "VarFileInfo"

View File

@ -36,6 +36,7 @@ LogWindow::LogWindow(DataProxy_SQLite *dp, QWidget *parent) : QWidget(parent)
util = new Utilities;
connect(logModel, SIGNAL(queryError(QString, QString, int, QString)), this, SLOT(slotQueryErrorManagement(QString, QString, int, QString)) );
logView = new QTableView;
//dxccStatusWidget = new DXCCStatusWidget(dataProxy);
//elogClublog = new eLogClubLog();
currentLog = -1;
@ -109,9 +110,9 @@ void LogWindow::createlogPanel(const int _currentLog)
logModel->createlogModel(currentLog);
//proxyModel->setSourceModel(logModel);
logView->setModel(logModel);
logView->setCurrentIndex(logModel->index(0, 0));
//setProxyModel(false);
//QString contestMode = dataProxy->getLogTypeOfUserLog(currentLog);
@ -141,7 +142,7 @@ void LogWindow::createlogPanel(const int _currentLog)
//logView->setItemDelegateForColumn(1, new ItemDelegate);
//logView->setItemDelegate(new QSqlRelationalDelegate(this));
logView->setSelectionMode(QAbstractItemView::SingleSelection);
logView->setSelectionMode(QAbstractItemView::ExtendedSelection);
logView->setSelectionBehavior(QAbstractItemView::SelectRows);
logView->resizeColumnsToContents();
logView->horizontalHeader()->setStretchLastSection(true);
@ -206,6 +207,7 @@ void LogWindow::refresh()
void LogWindow::createActions()
{
createActionsCommon();
showMenuRightButtonFromLogCreateActions();
}
void LogWindow::createActionsCommon()
@ -220,14 +222,53 @@ void LogWindow::slotRighButtonFromLog(const QPoint& pos)
{
//qDebug() << "LogWindow::slotshowRighButtonFromLog" << endl;
int row = (logView->indexAt(pos)).row();
showMenuRightButtonFromLogCreateActions();
rightButtonFromLogMenu(row);
QItemSelectionModel *select = logView->selectionModel();
if (select->hasSelection())
{
rightButtonMultipleFromLogMenu();
}
else
{
rightButtonFromLogMenu(row);
}
//TODO: To be added to the logWindow and create an action that emist the QSO id
}
void LogWindow::rightButtonMultipleFromLogMenu()
{
//qDebug() << "LogWindow::slotshowRighButtonMultipleFromLogMenu: " << endl;
QMenu menu(this);
menu.addAction(multipleDelQSOsFromLogAct);
//menu.addSeparator();
menu.addAction(multipleExportToADIFFromLogAct);
/*
menu.addSeparator();
QMenu *menuEQsl = menu.addMenu(tr("eQSL"));
menuEQsl->addAction(multipleQueueForLoTWFromLogAct);
menuEQsl->addAction(multipleQueueForClubLogFromLogAct);
menuEQsl->addAction(multipleQueueForEQSLFromLogAct);
menu.addMenu(menuEQsl);
QMenu *menuQslS = menu.addMenu(tr("QSL"));
QMenu *menuSentQsl = menuQslS->addMenu(tr("QSLs Send"));
menuSentQsl->addAction(multipleQslSentViaBureauFromLogAct);
menuSentQsl->addAction(multipleQslSentViaDirectFromLogAct);
QMenu *menuRcvdQsl = menuQslS->addMenu(tr("QSLs Rcvd"));
menuRcvdQsl->addAction(multipleQslRecViaBureauFromLogAct);
menuRcvdQsl->addAction(multipleQslRecViaDirectFromLogAct);
*/
menu.exec(QCursor::pos());
}
void LogWindow::rightButtonFromLogMenu(const int trow)
{
//qDebug() << "LogWindow::slotshowRighButtonFromLogMenu: " << QString::number(trow) << endl;
//qDebug() << "LogWindow::slotshowRighButtonFromLogMenu: " << QString::number(trow) << endl;
int _qsoID = ((logModel->index(trow, 0)).data(0)).toInt();
//qDebug() << "LogWindow::slotshowRighButtonFromLogMenu: QSOid: " << QString::number(_qsoID) << endl;
@ -244,7 +285,6 @@ void LogWindow::rightButtonFromLogMenu(const int trow)
menu.addAction(checkDXHeatFromLogAct);
checkDXHeatFromLogAct->setData(trow);
menu.addSeparator();
if (qslSent)
{
@ -348,6 +388,43 @@ void LogWindow::showMenuRightButtonFromLogCreateActions()
checkDXHeatFromLogAct->setStatusTip(tr("Check this callsign in DXHeat.com"));
connect(checkDXHeatFromLogAct, SIGNAL(triggered()), this, SLOT( slotCheckDXHeatCom() ));
multipleDelQSOsFromLogAct = new QAction(tr("Delete selected QSOs"), this);
//multipleDelQSOsFromLogAct->setShortcut(Qt::CTRL + Qt::Key_D);
multipleDelQSOsFromLogAct->setStatusTip(tr("Delete the selected QSOs"));
connect(multipleDelQSOsFromLogAct, SIGNAL(triggered()), this, SLOT(slotQSOsDeleteFromLog()));
multipleExportToADIFFromLogAct = new QAction(tr("Export to ADIF"), this);
//multipleExportToADIFFromLogAct->setShortcut(Qt::CTRL + Qt::Key_D);
multipleExportToADIFFromLogAct->setStatusTip(tr("Export the selected QSOs to an ADIF file."));
connect(multipleExportToADIFFromLogAct, SIGNAL(triggered()), this, SLOT(slotQSOsExportFromLog()));
multipleQueueForLoTWFromLogAct = new QAction(tr("Upload to LoTW"), this);
multipleQueueForLoTWFromLogAct->setStatusTip(tr("Upload the selected QSOs to LoTW"));
connect(multipleQueueForLoTWFromLogAct, SIGNAL(triggered()), this, SLOT(slotQSOsUploadToLoTWFromLog()));
multipleQueueForClubLogFromLogAct = new QAction(tr("Upload to ClubLog"), this);
multipleQueueForClubLogFromLogAct->setStatusTip(tr("Upload the selected QSOs to ClubLog"));
connect(multipleQueueForClubLogFromLogAct, SIGNAL(triggered()), this, SLOT(slotQSOsUploadToClubLogFromLog()));
multipleQueueForEQSLFromLogAct = new QAction(tr("Upload to eQSL.cc"), this);
multipleQueueForEQSLFromLogAct->setStatusTip(tr("Upload the selected QSOs to eQSL.cc"));
connect(multipleQueueForEQSLFromLogAct, SIGNAL(triggered()), this, SLOT(slotQSOsUploadToEQSLFromLog()));
multipleQslSentViaBureauFromLogAct = new QAction(tr("Via bureau"), this);
multipleQslSentViaBureauFromLogAct->setStatusTip(tr("Send these QSLs via bureau"));
connect(multipleQslSentViaBureauFromLogAct, SIGNAL(triggered()), this, SLOT( slotMultipleQSLSentViaBureauFromLog() ));
multipleQslSentViaDirectFromLogAct = new QAction(tr("Direct"), this);
multipleQslSentViaDirectFromLogAct->setStatusTip(tr("Send these QSLs via direct"));
connect(multipleQslSentViaDirectFromLogAct, SIGNAL(triggered()), this, SLOT( slotMultipleQSLSentViaDirectFromLog() ));
multipleQslRecViaBureauFromLogAct = new QAction(tr("Via bureau"), this);
multipleQslRecViaBureauFromLogAct->setStatusTip(tr("QSLs received via bureau"));
connect(multipleQslRecViaBureauFromLogAct, SIGNAL(triggered()), this, SLOT( slotMultipleQSLRecViaBureauFromLog() ));
multipleQslRecViaDirectFromLogAct = new QAction(tr("Direct"), this);
multipleQslRecViaDirectFromLogAct->setStatusTip(tr("QSLs received via direc&t"));
connect(multipleQslRecViaDirectFromLogAct, SIGNAL(triggered()), this, SLOT( slotMultipleQSLRecViaDirectFromLog() ));
}
@ -468,6 +545,87 @@ void LogWindow::slotQsoDeleteFromLog()
*/
}
void LogWindow::slotQSOsDeleteFromLog()
{
//qDebug() << "LogWindow::slotQSOsDeleteFromLog" << endl;
QItemSelectionModel *select = logView->selectionModel();
QList<int> qsos;
qsos.clear();
if (select->hasSelection())
{
QModelIndexList list = select->selectedRows();
foreach (QModelIndex index, list)
{
qsos.append(index.data(0).toInt());
//qDebug() << "LogWindow::slotshowRighButtonFromLog: " << QString::number(index.row()) << endl;
//qDebug() << "LogWindow::slotshowRighButtonFromLog: " << QString::number(index.data(0).toInt()) << endl;
}
}
if (qsos.length()>0)
{
emit deleteTheseQSOs(qsos);
}
}
void LogWindow::slotQSOsExportFromLog()
{
//qDebug() << "LogWindow::slotQSOsExportFromLog - TO BE IMPLEMENTED" << endl;
QItemSelectionModel *select = logView->selectionModel();
QList<int> qsos;
qsos.clear();
if (select->hasSelection())
{
QModelIndexList list = select->selectedRows();
foreach (QModelIndex index, list)
{
qsos.append(index.data(0).toInt());
//qDebug() << "LogWindow::slotQSOsExportFromLog: " << QString::number(index.row()) << endl;
//qDebug() << "LogWindow::slotQSOsExportFromLog: " << QString::number(index.data(0).toInt()) << endl;
}
}
if (qsos.length()>0)
{
emit exportToADIFTheseQSOs(qsos);
}
}
void LogWindow::slotQSOsUploadToLoTWFromLog()
{
//qDebug() << "LogWindow::slotQSOsUploadToLoTWFromLog - TO BE IMPLEMENTED" << endl;
}
void LogWindow::slotQSOsUploadToClubLogFromLog()
{
//qDebug() << "LogWindow::slotQSOsUploadToClubLogFromLog - TO BE IMPLEMENTED" << endl;
}
void LogWindow::slotQSOsUploadToEQSLFromLog()
{
//qDebug() << "LogWindow::slotQSOsUploadToEQSLFromLog - TO BE IMPLEMENTED" << endl;
}
void LogWindow::slotMultipleQSLSentViaBureauFromLog()
{
//qDebug() << "LogWindow::slotMultipleQSLSentViaBureauFromLog - TO BE IMPLEMENTED" << endl;
}
void LogWindow::slotMultipleQSLSentViaDirectFromLog()
{
//qDebug() << "LogWindow::slotMultipleQSLSentViaDirectFromLog - TO BE IMPLEMENTED" << endl;
}
void LogWindow::slotMultipleQSLRecViaBureauFromLog()
{
//qDebug() << "LogWindow::slotMultipleQSLRecViaBureauFromLog - TO BE IMPLEMENTED" << endl;
}
void LogWindow::slotMultipleQSLRecViaDirectFromLog()
{
//qDebug() << "LogWindow::slotMultipleQSLRecViaDirectFromLog - TO BE IMPLEMENTED" << endl;
}
void LogWindow::qslSentViaBureau(const int _qsoId)
{
//qDebug() << "LogWindow::qslSentViaBureau: " << QString::number(_qsoId)yyyy-MM-dd

View File

@ -76,6 +76,8 @@ signals:
//void qsoFound(const QStringList _qs); // Each: QString with format: Fieldname:value
void queryError(QString functionFailed, QString errorCodeS, int errorCodeN, QString failedQuery); // To alert about any failed query execution
//void clearError();
void deleteTheseQSOs(QList<int> _qsos);
void exportToADIFTheseQSOs(QList<int> _qsos);
private slots:
@ -92,6 +94,17 @@ private slots:
void slotCheckQRZCom();
void slotCheckDXHeatCom();
void slotQSOsDeleteFromLog();
void slotQSOsExportFromLog();
void slotQSOsUploadToLoTWFromLog();
void slotQSOsUploadToClubLogFromLog();
void slotQSOsUploadToEQSLFromLog();
void slotMultipleQSLSentViaBureauFromLog();
void slotMultipleQSLSentViaDirectFromLog();
void slotMultipleQSLRecViaBureauFromLog();
void slotMultipleQSLRecViaDirectFromLog();
private:
void createUI();
@ -100,6 +113,7 @@ private:
void deleteQSO(const int _qsoID);
void rightButtonFromLogMenu(const int trow);
void rightButtonMultipleFromLogMenu();
void showMenuRightButtonFromLogCreateActions();
@ -109,6 +123,7 @@ private:
DataProxy_SQLite *dataProxy;
LogModel *logModel;
//QItemSelectionModel *selectionModel;
Awards *awards;
//DXCCStatusWidget *dxccStatusWidget;
//eLogClubLog *elogClublog;
@ -125,6 +140,18 @@ private:
QAction *checkQRZCOMFromLogAct;
QAction *checkDXHeatFromLogAct;
//Multiple selection actions
QAction *multipleDelQSOsFromLogAct;
QAction *multipleExportToADIFFromLogAct;
QAction *multipleQueueForLoTWFromLogAct;
QAction *multipleQueueForClubLogFromLogAct;
QAction *multipleQueueForEQSLFromLogAct;
QAction *multipleQslSentViaBureauFromLogAct;
QAction *multipleQslSentViaDirectFromLogAct;
QAction *multipleQslRecViaBureauFromLogAct;
QAction *multipleQslRecViaDirectFromLogAct;
//QAction *moveToAnotherLog; // MOves the selected QSOs to another log.
int currentLog;
Utilities *util;

View File

@ -161,7 +161,7 @@ int LoTWUtilities::download()
//qDebug() << "LoTWUtilities::download: - 12" << endl;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - File exist"));
msgBox.setWindowTitle(tr("KLog - LoTW File already exists"));
QString aux = QString(tr("There is a file already existing with the name that will be used.") );
msgBox.setText(tr("The file %1 already exist. Do you want to overwrite?").arg(fileName));
msgBox.setDetailedText(aux);
@ -193,7 +193,7 @@ int LoTWUtilities::download()
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - Can't write the file"));
msgBox.setWindowTitle(tr("KLog - LoTW Can't write the file"));
QString aux = QString(tr("KLog was not able to save the file %1.\nError returned: %2") ).arg(fileName).arg(file->errorString());
msgBox.setText(tr("The file %1 already exists.").arg(fileName));
msgBox.setDetailedText(aux);
@ -291,7 +291,7 @@ void LoTWUtilities::slotFinished()
file->remove();
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - Download error"));
msgBox.setWindowTitle(tr("KLog - LoTW Download error"));
QString aux = QString(tr("The downloading error is: %1") ).arg(reply->errorString());
msgBox.setText(tr("There was an error while downloading the file from LoTW."));
msgBox.setDetailedText(aux);
@ -304,7 +304,7 @@ void LoTWUtilities::slotFinished()
QUrl newUrl = url.resolved(redirectionTarget.toUrl());
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - Redirection found"));
msgBox.setWindowTitle(tr("KLog - LoTW Redirection found"));
QString aux = QString(tr("The remote server redirected our connection to %1") ).arg(newUrl.toString());
msgBox.setText(tr("Do you want to follow the redirection?"));
msgBox.setDetailedText(aux);
@ -391,7 +391,7 @@ void LoTWUtilities::parseDownloadedFile(const QString &_fn)
{
//qDebug() << "LoTWUtilities::parseDownloadedFile File not found" << _fileName << endl;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - File not found"));
msgBox.setWindowTitle(tr("KLog - LoTW File not found"));
msgBox.setText(tr("KLog can't find the downloaded file."));
aux = QString(tr("It was not possible for find the file %1 that has been just downloaded.") ).arg(_fn);

View File

@ -36,7 +36,7 @@ int main(int argc, char *argv[])
//qDebug() << "KLog Main: Start! " << endl;
//qDebug() << "KLog Main: " << QSslSocket::supportsSsl() << QSslSocket::sslLibraryBuildVersionString() << QSslSocket::sslLibraryVersionString() << endl;
QDir d1 = QDir();
QString version = "1.4-RC1";
QString version = "1.4-RC5";
Utilities util = Utilities();
QStringList arguments;
QTextStream cout(stdout);

View File

@ -86,7 +86,7 @@ MainWindow::MainWindow(const QString &_klogDir, const QString &tversion)
dataProxy = new DataProxy_SQLite(softwareVersion, Q_FUNC_INFO);
lotwUtilities = new LoTWUtilities(klogDir, softwareVersion, Q_FUNC_INFO, dataProxy);
eqslUtilities = new eQSLUtilities(klogDir, softwareVersion, Q_FUNC_INFO, dataProxy);
eqslUtilities = new eQSLUtilities(Q_FUNC_INFO);
//qDebug() << "MainWindow::MainWindow: Before DXCCStatusWidget " << endl;
@ -500,6 +500,10 @@ void MainWindow::createActionsCommon(){
// LOGVIEW
connect(logWindow, SIGNAL(actionQSODoubleClicked ( int ) ), this, SLOT(slotDoubleClickLog( const int ) ) );
connect(logWindow, SIGNAL(actionDeleteQSO ( int ) ), this, SLOT(slotQSODelete(int) ) );
connect(logWindow, SIGNAL(deleteTheseQSOs ( QList<int> ) ), this, SLOT(slotQSOsDelete(QList<int>) ) );
connect(logWindow, SIGNAL(exportToADIFTheseQSOs ( QList<int> ) ), this, SLOT(slotQSOsExportToADIF(QList<int>) ) );
connect(logWindow, SIGNAL(updateAwards() ), this, SLOT(slotShowAwards() ) );
connect(logWindow, SIGNAL(updateSearchText()), this, SLOT(slotSearchBoxTextChanged() ) ); //When a QSO is deleted
connect(logWindow, SIGNAL(queryError(QString, QString, int, QString)), this, SLOT(slotQueryErrorManagement(QString, QString, int, QString)) );
@ -513,9 +517,12 @@ void MainWindow::createActionsCommon(){
connect (elogClublog, SIGNAL (showMessage(QString)), this, SLOT (slotElogClubLogShowMessage(QString)));
connect (elogClublog, SIGNAL (actionReturnDownload(int, int)), this, SLOT (slotElogClubLogProcessAnswer(int, int)));
connect (elogClublog, SIGNAL (disableClubLogAction(bool)), this, SLOT (slotElogClubLogDisable(bool)));
connect (elogClublog, SIGNAL (signalFileUploaded(int, QList<int>)), this, SLOT (slotElogClubLogFileUploaded(int, QList<int>)));
connect (elogClublog, SIGNAL (signalFileUploaded(QNetworkReply::NetworkError, QList<int>)), this, SLOT (slotElogClubLogFileUploaded(QNetworkReply::NetworkError, QList<int>)));
connect (eqslUtilities, SIGNAL (actionReturnDownload(int, int)), this, SLOT (slotElogClubLogProcessAnswer(int, int)));
//connect (eqslUtilities, SIGNAL (disableClubLogAction(bool)), this, SLOT (slotElogClubLogDisable(bool)));
connect (eqslUtilities, SIGNAL (showMessage(QString)), this, SLOT (slotElogClubLogShowMessage(QString)));
connect (eqslUtilities, SIGNAL (signalFileUploaded(QNetworkReply::NetworkError, QList<int>)), this, SLOT (slotElogEQSLFileUploaded(QNetworkReply::NetworkError, QList<int>)));
// SATELLITE TAB
//connect (satTabWidget, SIGNAL (satBandTXChanged(QString)), this, SLOT (slotSatBandTXComboBoxChanged(QString)));
//connect(satTabWidget, SIGNAL(returnPressed()), this, SLOT(slotQRZReturnPressed()) );
@ -646,7 +653,8 @@ void MainWindow::recommendBackupIfNeeded()
switch (ret)
{
case QMessageBox::Yes:
QString filename = (QDateTime::currentDateTime()).toString("yyyyMMdd-hhmm") + "-klogbackup.adi";
//QString filename = (QDateTime::currentDateTime()).toString("yyyyMMdd-hhmm") + "-klogbackup.adi";
QString filename = util->getBackupADIFile();
filemanager->adifLogExport(filename, 0); // 0 will save ALL the logs
break;
}
@ -937,7 +945,7 @@ void MainWindow::actionsJustAfterAddingOneQSO()
yearChangedDuringModification = false;
}
if ((clublogActive) & (clublogRealTime))
if ((clublogActive) && (clublogRealTime))
{
//qDebug() << "MainWindow::actionsJustAfterAddingOneQSO: (Modifiying ClubLog) Lastid: "<< QString::number(lastId) << endl;
// Delete QSO in CLubLog
@ -2507,6 +2515,83 @@ void MainWindow::slotSearchBoxTextChanged()
logEvent(Q_FUNC_INFO, "END", logSeverity);
}
void MainWindow::slotQSOsExportToADIF(QList<int> _id)
{
//qDebug() << "MainWindow::slotQSOsExportToADIF " << QString::number(_id.length()) << endl;
if (_id.length()<1)
{
return; // NO QSO TO EXPORT
}
foreach(int i, _id)
{
//qDebug() << "MainWindow::slotQSOsExportToADIFF " << QString::number(i) << endl;
}
QString fileName = QFileDialog::getSaveFileName(this, tr("Save ADIF File"), util->getHomeDir(), "ADIF (*.adi *.adif)");
//qDebug() << "MainWindow::slotQSOsExportToADIF: " << fileName << endl;
if ((!fileName.endsWith(".adi")) && ( !fileName.endsWith(".adif") ))
{
//qDebug() << "MainWindow::slotQSOsExportToADIF: Adding the .adi to the file" << fileName << endl;
fileName = fileName + ".adi";
}
//qDebug() << "MainWindow::slotQSOsExportToADIF-1: " << fileName << endl;
filemanager->adifQSOsExport(fileName, _id);
//qDebug() << "MainWindow::slotQSOsExportToADIF-3" << endl;
showNumberOfSavedQSO(fileName, _id.count());
//qDebug() << "MainWindow::slotQSOsExportToADIF - END" << endl;
}
void MainWindow::slotQSOsDelete(QList<int> _id)
{
//qDebug() << "MainWindow::slotQSOsDelete " << QString::number(_id.length()) << endl;
//foreach(int i, _id)
//{
// //qDebug() << "MainWindow::slotQSOsDelete " << QString::number(i) << endl;
//}
QString message = QString(tr("You have requested to delete several QSOs "));
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setText(message);
msgBox.setDetailedText(tr("This operation shall remove definetly all the selected QSO and associated data and you will not be able to recover it again."));
msgBox.setInformativeText(tr("Are you sure?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
switch (ret)
{
case QMessageBox::Yes :
foreach (int i, _id)
{
QStringList qsoToDelete;
qsoToDelete.clear();
qsoToDelete << dataProxy->getClubLogRealTimeFromId(i);
if(dataProxy->deleteQSO(i))
{
//qDebug() << "MainWindow::slotQSODelete: Just removed from log, now I will try to remove from ClubLog, if needed" << endl;
if (clublogActive && clublogRealTime)
{
//qDebug() << "MainWindow::slotQSODelete: Removing from ClubLog" << endl;
elogClublog->deleteQSO(qsoToDelete);
}
else
{
//qDebug() << "MainWindow::slotQSODelete: NOT emoving from ClubLog" << endl;
}
}
}
logWindow->refresh();
slotShowAwards();
break;
case QMessageBox::No :
break;
}
}
void MainWindow::slotQSODelete(const int _id)
{
logEvent(Q_FUNC_INFO, "Start", logSeverity);
@ -2539,8 +2624,17 @@ void MainWindow::slotQSODelete(const int _id)
qsoToDelete << dataProxy->getClubLogRealTimeFromId(QSOid);
if(dataProxy->deleteQSO(QSOid))
{
//qDebug() << "MainWindow::slotQSODelete: Just removed from log, now I will try to remove from ClubLog, if needed" << endl;
if (clublogActive && clublogRealTime)
{
//qDebug() << "MainWindow::slotQSODelete: Removing from ClubLog" << endl;
elogClublog->deleteQSO(qsoToDelete);
}
else
{
//qDebug() << "MainWindow::slotQSODelete: NOT emoving from ClubLog" << endl;
}
elogClublog->deleteQSO(qsoToDelete);
logWindow->refresh();
slotShowAwards();
//emit updateSearchText();
@ -2615,12 +2709,26 @@ void MainWindow::slotElogClubLogDisable(const bool _b)
logEvent(Q_FUNC_INFO, "END", logSeverity);
}
void MainWindow::slotElogClubLogFileUploaded (const int _reply, QList<int> _qsos)
void MainWindow::slotElogClubLogFileUploaded (QNetworkReply::NetworkError _error, QList<int> _qsos)
{
//qDebug() << "MainWindow::slotElogClubLogFileUploaded: " << QString::number(_reply) << endl;
bool uploadedToClubLog = false;
QString fileName = "klog-clublog-upload.adi";
QMessageBox msgBox;
if (_error != QNetworkReply::NoError)
{
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog ClubLog error"));
msgBox.setText(tr("The ClubLog upload process has finished with an error and the log was possibly not uploaded."));
msgBox.setDetailedText(tr("Please check your credentials, your Internet connection and your Clublog account. The received error code was: %1").arg(_error));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
return;
}
QString fileName = util->getClubLogFile();
if (QFile::exists(fileName))
{
//qDebug() << "MainWindow::slotElogClubLogFileUploaded file exist" << endl;
@ -2629,38 +2737,31 @@ void MainWindow::slotElogClubLogFileUploaded (const int _reply, QList<int> _qsos
{
//qDebug() << "MainWindow::slotElogClubLogFileUploaded file DOES NOT exist" << endl;
}
int i = _reply;
if (i == 0)
{
uploadedToClubLog = true;
}
QMessageBox msgBox;
if (uploadedToClubLog)
{
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog ClubLog"));
msgBox.setText(tr("Do you want to mark as Uploaded all the QSOs uploaded to ClubLog?") );
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No );
msgBox.setDefaultButton(QMessageBox::Yes);
int i = msgBox.exec();
if (i == QMessageBox::Yes)
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog ClubLog"));
msgBox.setText(tr("Do you want to mark as Uploaded all the QSOs uploaded to ClubLog?") );
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No );
msgBox.setDefaultButton(QMessageBox::Yes);
int i = msgBox.exec();
if (i == QMessageBox::Yes)
{
bool uploadedToClubLog = dataProxy->clublogSentQSOs(_qsos);
// TODO: Check if QSOS where sent
if (!uploadedToClubLog)
{
uploadedToClubLog = dataProxy->clublogSentQSOs(_qsos);
// TODO: Check if QSOS where sent
if (!uploadedToClubLog)
{
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - ClubLog"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("There was an error while updating to Yes the ClubLog QSO upload information."));
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - ClubLog"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("There was an error while updating to Yes the ClubLog QSO upload information."));
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
}
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog ClubLog"));
@ -2724,6 +2825,95 @@ void MainWindow::slotElogClubLogProcessAnswer(const int _i, const int _qID)
}
void MainWindow::slotElogEQSLFileUploaded (QNetworkReply::NetworkError _error, QList<int> _qsos)
{
//qDebug() << "MainWindow::slotElogEQSLFileUploaded: " << QString::number(_error) << endl;
QMessageBox msgBox;
if (_error != QNetworkReply::NoError)
{
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog eQSL error"));
msgBox.setText(tr("The eQSL upload process has finished with an error and the log was possibly not uploaded."));
msgBox.setDetailedText(tr("Please check your credentials, your Internet connection and your eQSL account. The received error code was: %1").arg(_error));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
return;
}
QString fileName = util->getEQSLFile();
if (QFile::exists(fileName))
{
//qDebug() << "MainWindow::slotElogEQSLFileUploaded file exist" << endl;
}
else
{
//qDebug() << "MainWindow::slotElogEQSLFileUploaded file DOES NOT exist" << endl;
}
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog eQSL"));
msgBox.setText(tr("Do you want to mark as Uploaded all the QSOs uploaded to eQSL?") );
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No );
msgBox.setDefaultButton(QMessageBox::Yes);
int i = msgBox.exec();
if (i == QMessageBox::Yes)
{
bool uploadedToeQSL = dataProxy->eQSLSentQSOs(_qsos);
// TODO: Check if QSOS where sent
if (!uploadedToeQSL)
{
QMessageBox msgBox;
msgBox.setWindowTitle(tr("KLog - eQSL"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("There was an error while updating to Yes the eQSL QSO upload information."));
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog eQSL"));
msgBox.setText(tr("The eQSL upload process has finished and KLog created a file (%1) in your KLog folder.\n\nDo you want KLog to remove that file?").arg(fileName));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No );
msgBox.setDefaultButton(QMessageBox::Yes);
i = msgBox.exec();
if (i == QMessageBox::Yes)
{
if (QFile::remove(fileName))
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(tr("KLog eQSL"));
msgBox.setText(tr("The file has been removed."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
//qDebug() << "MainWindow::slotElogEQSLFileUploaded - FILE REMOVED: " << fileName << endl;
}
else
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(tr("KLog eQSL"));
msgBox.setText(tr("The file has not been removed."));
msgBox.setDetailedText(tr("It seems that there was something that prevented KLog from removing the file\nYou can remove it manually."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
//qDebug() << "MainWindow::slotElogEQSLFileUploaded - FILE NOT REMOVED: " << fileName << endl;
}
i = msgBox.exec();
}
//qDebug() << "MainWindow::slotElogEQSLFileUploaded - END" << endl;
}
void MainWindow::slotExitFromSlotDialog(const int exitID)
{
//qDebug()() << "MainWindow::slotExitFromSlotDialog: " << QString::number(exitID) << endl;
@ -3054,6 +3244,7 @@ void MainWindow::slotClearButtonClicked()
mainQSOEntryWidget->clear();
clearUIDX(true);
//completedWithPreviousName = false;
statusBar()->clearMessage();
setCleaning(false);
@ -3349,7 +3540,18 @@ void MainWindow::createMenusCommon()
connect(clublogLogUploadAct, SIGNAL(triggered()), this, SLOT(slotClubLogLogUpload()));
clublogLogUploadAct->setToolTip("Uploads your log to ClubLog. Please ensure that you have created log for that callsign before uploading.");
toolMenu->addSeparator();
eQSLToolMenu = toolMenu->addMenu(tr("eQSL tools..."));
eqslLogModifyCurrentLogAct = new QAction(tr("Mark all the QSO to be uploaded"), this);
eQSLToolMenu->addAction(eqslLogModifyCurrentLogAct);
connect(eqslLogModifyCurrentLogAct, SIGNAL(triggered()), this, SLOT( slotElogEQSLModifyCurrentLog()));
eqslLogModifyCurrentLogAct->setToolTip("Mark as modified all the QSO so they can be uploaded againto eQSL.");
eqslUploadAct = new QAction(tr("Upload the log to eQSL.cc"), this);
eQSLToolMenu->addAction(eqslUploadAct);
connect(eqslUploadAct, SIGNAL(triggered()), this, SLOT(sloteQSLLogUpload()));
eqslUploadAct->setToolTip("Uploads your log to eQSL.cc.");
toolMenu->addSeparator();
@ -5617,7 +5819,9 @@ void MainWindow::fileExportLoTW(const QString &_st, const QDate &_startDate, con
return;
}
QString fileName = "klog-lotw-upload.adi";
//QString fileName = "klog-lotw-upload.adi";
QString fileName = util->getLoTWAdifFile();
QList<int> qsos = filemanager->adifLogExportReturnList(fileName, _st, _startDate, _endDate, currentLog, ModeLotW);
@ -5703,7 +5907,8 @@ void MainWindow::fileExportClubLog(const QString &_st, const QDate &_startDate,
return;
}
QString fileName = "klog-clublog-upload.adi";
//QString fileName = "klog-clublog-upload.adi";
QString fileName = util->getClubLogFile();
QList<int> qsos = filemanager->adifLogExportReturnList(fileName, _st, _startDate, _endDate, currentLog, ModeClubLog);
@ -5712,14 +5917,95 @@ void MainWindow::fileExportClubLog(const QString &_st, const QDate &_startDate,
//qDebug() << "MainWindow::fileExportClubLog NO QSOs" << endl;
return;
}
msgBox.setWindowTitle(tr("KLog - ClubLog"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("Do you want to add this QSOs to your ClubLog existing log?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::No);
msgBox.setDetailedText(tr("If you don't agree, this upload will overwrite your current ClubLog existing log."));
msgBox.setDefaultButton(QMessageBox::Ok);
int ret = msgBox.exec();
bool overwrite = false;
switch (ret)
{
case QMessageBox::Ok: // General ADIF
overwrite = false;
break;
case QMessageBox::No: // ClubLog
overwrite = true;
break;
}
//qDebug() << "MainWindow::fileExportClubLog - 50" << endl;
elogClublog->sendLogFile(fileName, qsos);
elogClublog->sendLogFile(fileName, qsos, overwrite);
//qDebug() << "MainWindow::fileExportClubLog -END " << endl;
}
void MainWindow::fileExportEQSL(const QString &_st, const QDate &_startDate, const QDate &_endDate)
{
//qDebug() << "MainWindow::fileExportEQSL - Start: " << _st << "/" <<_startDate.toString("yyyyMMdd") <<"/" << _endDate.toString("yyyyMMdd") << endl;
QMessageBox msgBox;
if (!util->isValidCall(_st))
{
//qDebug() << "MainWindow::fileExportEQSL - no valid call" << endl;
if (_st == "ALL")
{
msgBox.setWindowTitle(tr("KLog - eQSL"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("You need to select one station callsign to be able to send your log to eQSL.cc."));
msgBox.setStandardButtons(QMessageBox::Ok );
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
return;
}
if ((!_startDate.isValid()) || (!_endDate.isValid()))
{
//qDebug() << "MainWindow::fileExportEQSL - no valid date" << endl;
return;
}
//QString fileName = "klog-eqsl-upload.adi";
QString fileName = util->getEQSLFile();
//QString eQSLUser = ;
//QString eQSLPass = ;
QList<int> qsos = filemanager->adifLogExportReturnList(fileName, _st, _startDate, _endDate, currentLog, ModeEQSL);
if (qsos.count() <= 0)
{ // TODO: Check if errors should be managed.
//qDebug() << "MainWindow::fileExportEQSL NO QSOs" << endl;
return;
}
/*
msgBox.setWindowTitle(tr("KLog - eQSL"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("Do you want to add this QSOs to your eQSL existing log?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::No);
msgBox.setDetailedText(tr("If you don't agree, this upload will overwrite your current ClubLog existing log."));
msgBox.setDefaultButton(QMessageBox::Ok);
int ret = msgBox.exec();
bool overwrite = false;
switch (ret)
{
case QMessageBox::Ok:
overwrite = false;
break;
case QMessageBox::No:
overwrite = true;
break;
}
//qDebug() << "MainWindow::fileExportEQSL - 50" << endl;
*/
eqslUtilities->sendLogFile(fileName, qsos);
//qDebug() << "MainWindow::fileExportEQSL -END " << endl;
}
void MainWindow::slotADIFExportSelection(const QString &_st, const QDate &_startDate, const QDate &_endDate, const ExportMode _eM)
{
@ -5739,6 +6025,10 @@ void MainWindow::slotADIFExportSelection(const QString &_st, const QDate &_start
//qDebug() << "MainWindow::slotADIFExportSelection - ClubLog" << endl;
fileExportClubLog(_st, _startDate, _endDate);
break;
case ModeEQSL: // General eQSL
//qDebug() << "MainWindow::slotADIFExportSelection - ClubLog" << endl;
fileExportEQSL(_st, _startDate, _endDate);
break;
}
//qDebug() << "MainWindow::slotADIFExportSelection -END " << endl;
@ -5821,6 +6111,30 @@ void MainWindow::slotElogClubLogModifyCurrentLog()
msgBox.exec();
}
void MainWindow::slotElogEQSLModifyCurrentLog()
{
QMessageBox msgBox;
if (dataProxy->eQSLModifyFullLog(currentLog))
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("The log is ready to be uploaded to eQSL.cc."));
msgBox.setDetailedText(tr("All the QSOs in this log has been marked as Modified in the eQSL.cc status field"));
}
else
{
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("KLog could not mark the full log to be sent to eQSL"));
msgBox.setDetailedText(tr("Something prevented KLog from marking the QSOs as modified. Restart KLog and try again before contacting the KLog developers."));
}
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
void MainWindow::slotClubLogLogUpload()
{
logEvent(Q_FUNC_INFO, "Start", logSeverity);
@ -5830,6 +6144,15 @@ void MainWindow::slotClubLogLogUpload()
logEvent(Q_FUNC_INFO, "END", logSeverity);
}
void MainWindow::sloteQSLLogUpload()
{
logEvent(Q_FUNC_INFO, "Start", logSeverity);
adifLoTWExportWidget->setExportMode(ModeEQSL);
adifLoTWExportWidget->show();
logEvent(Q_FUNC_INFO, "END", logSeverity);
}
void MainWindow::slotRQSLExport()
{
logEvent(Q_FUNC_INFO, "Start", logSeverity);
@ -7161,12 +7484,13 @@ void MainWindow::slotSetPropMode(const QString &_p)
void MainWindow::completeWithPreviousQSO(const QString &_call)
{
//qDebug() << "MainWindow::completeWithPreviousQSO" << endl;
//qDebug() << "MainWindow::completeWithPreviousQSO" << endl;
//This function completes: Name, QTH, Locator, Entity, Iota
logEvent(Q_FUNC_INFO, "Start", logSeverity);
if ((!completeWithPrevious) || (_call.length()<=0) || (dataProxy->isWorkedB4(_call, -1)<=0))
//if ( (_call.length()<=0) || (dataProxy->isWorkedB4(_call, -1)<=0))
{
//qDebug() << "MainWindow::completeWithPreviousQSO NOT completing..." << endl;
if (completedWithPreviousName)
{
nameLineEdit->clear();
@ -7204,24 +7528,33 @@ void MainWindow::completeWithPreviousQSO(const QString &_call)
logEvent(Q_FUNC_INFO, "END-1", logSeverity);
return;
}
//qDebug() << "MainWindow::completeWithPreviousQSO completing..." << endl;
QString aux = QString();
aux = dataProxy->getNameFromQRZ(_call);
//qDebug() << "MainWindow::completeWithPreviousQSO aux: " << aux << endl;
//qDebug() << "MainWindow::completeWithPreviousQSO nameLineEdit: " << nameLineEdit->text() << endl;
//qDebug() << "MainWindow::completeWithPreviousQSO aux length: " << QString::number(aux.length()) << endl;
//qDebug() << "MainWindow::completeWithPreviousQSO nameL length: " << QString::number((nameLineEdit->text()).length()) << endl;
if ((aux.length()>=0) && ((nameLineEdit->text()).length()<=0) )
{
//qDebug() << "MainWindow::completeWithPreviousQSO name: 1" << endl;
nameLineEdit->setPalette(palRed);
completedWithPreviousName = true;
nameLineEdit->setText(aux);
}
else if (completedWithPreviousName)
else if (completedWithPreviousName && (aux != nameLineEdit->text()))
{
//qDebug() << "MainWindow::completeWithPreviousQSO name: 2" << endl;
nameLineEdit->clear();
completedWithPreviousName = false;
nameLineEdit->setPalette(palBlack);
}
else
{
//qDebug() << "MainWindow::completeWithPreviousQSO name: 3" << endl;
}
aux = dataProxy->getQTHFromQRZ(_call);
@ -7231,7 +7564,7 @@ void MainWindow::completeWithPreviousQSO(const QString &_call)
completedWithPreviousQTH = true;
qthLineEdit->setText(aux);
}
else if (completedWithPreviousQTH)
else if (completedWithPreviousQTH && (aux != qthLineEdit->text()))
{
qthLineEdit->clear();
completedWithPreviousQTH = false;
@ -7246,7 +7579,7 @@ void MainWindow::completeWithPreviousQSO(const QString &_call)
locatorLineEdit->setText(aux);
completedWithPreviousLocator=true;
}
else if (completedWithPreviousLocator)
else if (completedWithPreviousLocator && (aux != locatorLineEdit->text()))
{
locatorLineEdit->clear();
completedWithPreviousLocator = false;
@ -7271,13 +7604,13 @@ void MainWindow::completeWithPreviousQSO(const QString &_call)
//iotaNumberLineEdit->setText(values.at(1));
completedWithPreviousIOTA=true;
}
else if (completedWithPreviousIOTA)
else if (completedWithPreviousIOTA && (aux != othersTabWidget->getIOTA()))
{
othersTabWidget->clearIOTA();
completedWithPreviousName = false;
}
}
else if (completedWithPreviousIOTA)
else if (completedWithPreviousIOTA )
{
othersTabWidget->clearIOTA();
completedWithPreviousIOTA = false;
@ -7290,7 +7623,7 @@ void MainWindow::completeWithPreviousQSO(const QString &_call)
QSLTabWidget->setQSLVia(aux, Qt::red);
completedWithPreviousQSLVia=true;
}
else if (completedWithPreviousQSLVia)
else if (completedWithPreviousQSLVia && (aux != QSLTabWidget->getQSLVia()))
{
QSLTabWidget->setQSLVia("");
}

View File

@ -174,6 +174,8 @@ private slots:
//void slotLoTWTest();
void slotClubLogLogUpload();
void sloteQSLLogUpload();
void slotElogEQSLModifyCurrentLog();
//void slotModeComboBoxChanged();
//void slotBandComboBoxChanged();
//void slotIOTAComboBoxChanged();
@ -189,6 +191,8 @@ private slots:
void slotLogRefresh();
//void slotScoreWinShow();
void slotQSODelete(const int _id);
void slotQSOsDelete(QList<int> _id);
void slotQSOsExportToADIF(QList<int> _id);
void slotShowAwards();
void slotUpdateStatusBar(const QString &statusm);
@ -272,10 +276,13 @@ private slots:
void slotElogClubLogShowMessage(const QString &_s);
void slotElogClubLogProcessAnswer(const int _i, const int _qID);
void slotElogClubLogDisable(const bool _b);
void slotElogClubLogFileUploaded (const int _reply, QList<int> _qsos);
void slotElogClubLogFileUploaded (QNetworkReply::NetworkError _error, QList<int> _qsos);
void slotElogClubLogModifyCurrentLog();
//CLUBLOG
//CLUBLOG
// EQSL
void slotElogEQSLFileUploaded (QNetworkReply::NetworkError _error, QList<int> _qsos);
// EQSL
void slotShowSoftUpdateResults(const bool _b); // Software Update: Receives the signal to see if it is needed or not to update
//SATELLITE
@ -334,6 +341,7 @@ private:
void updateBandComboBox(const QString &_band);
void fileExportLoTW(const QString &_st, const QDate &_startDate, const QDate &_endDate);
void fileExportClubLog(const QString &_st, const QDate &_startDate, const QDate &_endDate);
void fileExportEQSL(const QString &_st, const QDate &_startDate, const QDate &_endDate);
void fileExportADIF(const QString &_st, const QDate &_startDate, const QDate &_endDate);
bool callTQSL(const QString &_filename, const QString &_call);
void showNumberOfSavedQSO(const QString &_fn, const int _n);
@ -481,6 +489,7 @@ private:
QMenu *qslToolMenu;
QMenu *lotwToolMenu;
QMenu *clublogToolMenu;
QMenu *eQSLToolMenu;
//QMenu *lotwMarkAllAsQueuedMenu;
//QMenu *lotwMarkAllInThisLogAsQueuedMenu;
QMenu *viewMenu;
@ -527,6 +536,8 @@ private:
QAction *clublogLogUploadAct;
QAction *clublogLogModifyCurrentLogAct;
QAction *eqslUploadAct;
QAction *eqslLogModifyCurrentLogAct;
QAction *downloadCTYAct;
QAction *downloadSATSAct;

View File

@ -79,9 +79,10 @@ SetupDialog::SetupDialog(DataProxy_SQLite *dp, const bool _firstTime)
//qDebug() << "SetupDialog::SetupDialog 3.10" << endl;
logsPage = new SetupPageLogs(dataProxy, this);
//qDebug() << "SetupDialog::SetupDialog 3.11" << endl;
clubLogPage = new SetupPageClubLog(this);
lotwPage = new SetupPageLoTW(this);
eQSLPage = new SetupPageEQSL(this);
eLogPage = new SetupPageELog(this);
//clubLogPage = new SetupPageClubLog(this);
//lotwPage = new SetupPageLoTW(this);
//eQSLPage = new SetupPageEQSL(this);
//qDebug() << "SetupDialog::SetupDialog 3.12" << endl;
UDPPage = new SetupPageUDP(this);
//qDebug() << "SetupDialog::SetupDialog 3.13" << endl;
@ -98,9 +99,10 @@ SetupDialog::SetupDialog(DataProxy_SQLite *dp, const bool _firstTime)
tabWidget->addTab(miscPage, tr("Misc"));
tabWidget->addTab(worldEditorPage, tr("World Editor"));
logsPageTabN = tabWidget->addTab(logsPage, tr("Logs"));
tabWidget->addTab(clubLogPage, "ClubLog");
tabWidget->addTab(lotwPage, "LoTW");
tabWidget->addTab(eQSLPage, "eQSL");
tabWidget->addTab(eLogPage, "eLog");
//tabWidget->addTab(clubLogPage, "ClubLog");
//tabWidget->addTab(lotwPage, "LoTW");
//tabWidget->addTab(eQSLPage, "eQSL");
tabWidget->addTab(UDPPage, "WSJT-X");
tabWidget->addTab(satsPage , tr("Satellites"));
tabWidget->addTab(hamlibPage, tr ("HamLib"));
@ -179,9 +181,10 @@ SetupDialog::SetupDialog(DataProxy_SQLite *dp, const QString &_configFile, const
miscPage = new SetupPageMisc(this);
worldEditorPage = new SetupPageWorldEditor (dataProxy, this);
logsPage = new SetupPageLogs(dataProxy, this);
clubLogPage = new SetupPageClubLog(this);
lotwPage = new SetupPageLoTW(this);
eQSLPage = new SetupPageEQSL(this);
eLogPage = new SetupPageELog(this);
//clubLogPage = new SetupPageClubLog(this);
//lotwPage = new SetupPageLoTW(this);
//eQSLPage = new SetupPageEQSL(this);
UDPPage = new SetupPageUDP(this);
satsPage = new SetupPageSats(dataProxy, this);
hamlibPage = new SetupPageHamLib(dataProxy, this);
@ -196,9 +199,10 @@ SetupDialog::SetupDialog(DataProxy_SQLite *dp, const QString &_configFile, const
tabWidget->addTab(miscPage, tr("Misc"));
tabWidget->addTab(worldEditorPage, tr("World Editor"));
logsPageTabN = tabWidget->addTab(logsPage, tr("Logs"));
tabWidget->addTab(clubLogPage, tr("ClubLog"));
tabWidget->addTab(lotwPage, tr("LoTW"));
tabWidget->addTab(eQSLPage, tr("eQSL"));
tabWidget->addTab(eLogPage, tr("eLog"));
//tabWidget->addTab(clubLogPage, tr("ClubLog"));
//tabWidget->addTab(lotwPage, tr("LoTW"));
tabWidget->addTab(UDPPage, tr("WSJT-X"));
tabWidget->addTab(satsPage , tr("Satellites"));
tabWidget->addTab(hamlibPage, tr ("HamLib"));
@ -261,9 +265,9 @@ void SetupDialog::connectActions()
connect (userDataPage, SIGNAL(stationCallSignal(QString)), this, SLOT(slotSetStationCallSign(QString)));
connect (userDataPage, SIGNAL(operatorsSignal(QString)), this, SLOT(slotSetOperators(QString)));
connect (userDataPage, SIGNAL(enterKey()), this, SLOT(slotOkButtonClicked()));
connect (lotwPage, SIGNAL(enterKey()), this, SLOT(slotOkButtonClicked()));
connect (eQSLPage, SIGNAL(enterKey()), this, SLOT(slotOkButtonClicked()));
connect (clubLogPage, SIGNAL(enterKey()), this, SLOT(slotOkButtonClicked()));
//connect (lotwPage, SIGNAL(enterKey()), this, SLOT(slotOkButtonClicked()));
connect (eLogPage, SIGNAL(enterKey()), this, SLOT(slotOkButtonClicked()));
//connect (clubLogPage, SIGNAL(enterKey()), this, SLOT(slotOkButtonClicked()));
emit debugLog (Q_FUNC_INFO, "END", logSeverity);
@ -430,7 +434,7 @@ void SetupDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous
void SetupDialog::slotOkButtonClicked()
{
//qDebug() << "SetupDialog::slotOkButtonClicked" << endl;
//qDebug() << "SetupDialog::slotOkButtonClicked" << endl;
emit debugLog (Q_FUNC_INFO, "Start", logSeverity);
if (!miscPage->areDBPathChangesApplied())
@ -456,7 +460,7 @@ void SetupDialog::slotOkButtonClicked()
if (!haveAtleastOneLog())
{
//qDebug() << "SetupDialog::slotOkButtonClicked - NO LOG!" << endl;
//qDebug() << "SetupDialog::slotOkButtonClicked - NO LOG!" << endl;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
@ -471,7 +475,7 @@ void SetupDialog::slotOkButtonClicked()
emit debugLog (Q_FUNC_INFO, "END-3", logSeverity);
return;
}
//qDebug() << "SetupDialog::slotOkButtonClicked - 10" << endl;
QFile file (configFileName);
QString tmp;
tmp = "true";
@ -563,7 +567,7 @@ void SetupDialog::slotOkButtonClicked()
{
stream << "Power=" << userDataPage->getPower() << ";" << endl;
}
//qDebug() << "SetupDialog::slotOkButtonClicked - 20" << endl;
//stream << "locator=" << (MyLocatorkLineEdit->text ()).toUpper () << ";" << endl;
//stream << "CallUsed=" << (UserDataPage.qrzLineEdit).text() << ";" << endl;
//stream << "Operators=" << ";" << endl;
@ -591,7 +595,7 @@ void SetupDialog::slotOkButtonClicked()
//stream << "PSTRotatorServer=" << interfacesWindowsPage->getPSTRotatorUDPServer() << ";" << endl;
//stream << "PSTRotatorPort=" << interfacesWindowsPage->getPSTRotatorUDPServerPort() << ";" << endl;
//qDebug() << "SetupDialog::slotOkButtonClicked - 30" << endl;
if ((miscPage->getReportInfo()).toUpper() == "TRUE")
{
stream << "ProvideInfo=True;" << endl;
@ -633,47 +637,86 @@ void SetupDialog::slotOkButtonClicked()
stream << "SelectedLog=" << QString::number(logsPage->getSelectedLog()) << ";" << endl;
// CLUBLOG
if (((clubLogPage->getClubLog()).toUpper() == "TRUE" ) && (clubLogPage->getPassword().length()>0) && (clubLogPage->getEmail().length()>2) )
//qDebug() << "SetupDialog::slotOkButtonClicked - 40" << endl;
if ((( (eLogPage->getClubLogActive())).toUpper() == "TRUE" ) && (eLogPage->getClubLogEmail().length()>2) )
{ //TODO: Add a isValidEmail funcion in the clibLogPage
stream << "ClubLogActive=" << clubLogPage->getClubLog() << ";" << endl;
stream << "ClubLogRealTime=" << clubLogPage->getClubLogRealTime() << ";" << endl;
//stream << "ClubLogCall=" << clubLogPage->getCallsign() << ";" << endl;
stream << "ClubLogPass=" << clubLogPage->getPassword() << ";" << endl;
stream << "ClubLogEmail=" << clubLogPage->getEmail() << ";" << endl;
//stream << "ClubLogUseStationCallsign=" << clubLogPage->getUseQSOStationCallsign() << ";" << endl;
tmp = eLogPage->getClubLogActive();
if (tmp.length()>0)
{
stream << "ClubLogActive=" << tmp << ";" << endl;
}
tmp = eLogPage->getClubLogRealTime();
if (tmp.length()>0)
{
stream << "ClubLogRealTime=" << tmp << ";" << endl;
}
tmp = eLogPage->getClubLogEmail() ;
if (tmp.length()>0)
{
stream << "ClubLogEmail=" << tmp << ";" << endl;
}
tmp = eLogPage->getClubLogPassword() ;
if (tmp.length()>0)
{
stream << "ClubLogPass=" << tmp << ";" << endl;
}
}
//qDebug() << "SetupDialog::slotOkButtonClicked - 50" << endl;
// eQSL
if (((eLogPage->getEQSLActive()).toUpper() == "TRUE" ) && (eLogPage->getEQSLEmail().length()>0) )
{
tmp = eLogPage->getEQSLActive();
if (tmp.length()>0)
{
stream << "eQSLActive=" << tmp << ";" << endl;
}
/*
tmp = eLogPage->getEQSLRealTime();
if (tmp.length()>0)
{
stream << "eQSLRealTime=" << tmp << ";" << endl;
}
*/
tmp = eLogPage->getEQSLEmail();
if (tmp.length()>0)
{
stream << "eQSLCall==" << tmp << ";" << endl;
}
tmp = eLogPage->getEQSLPassword() ;
if (tmp.length()>0)
{
stream << "eQSLPass=" << tmp << ";" << endl;
}
}
// eQSL
if (((eQSLPage->getActive()).toUpper() == "TRUE" ) && (eQSLPage->getCallsign().length()>0) && (eQSLPage->getPassword().length()>0))
{
stream << "eQSLActive=" << eQSLPage->getActive() << ";" << endl;
stream << "eQSLCall=" << eQSLPage->getCallsign() << ";" << endl;
stream << "eQSLPass=" << eQSLPage->getPassword() << ";" << endl;
stream << "eQSLRealTime=" << eQSLPage->getRealTime() << ";" << endl;
stream << "eQSLUseStationCallsign=" << eQSLPage->getUseQSOStationCallsign() << ";" << endl;
}
//qDebug() << "SetupDialog::slotOkButtonClicked - 60" << endl;
// LOTW
stream << "LoTWActive=" << lotwPage->getLoTW() << ";" << endl;
tmp = lotwPage->getPath();
stream << "LoTWActive=" << eLogPage->getLoTWActive() << ";" << endl;
tmp = eLogPage->getTQSLPath();
if (tmp.length()>0)
{
stream << "LoTWPath=" << tmp << ";" << endl;
}
tmp = lotwPage->getLoTWUser();
tmp = eLogPage->getLoTWUser();
if (tmp.length()>0)
{
stream << "LoTWUSer=" << tmp << ";" << endl;
}
tmp = lotwPage->getLoTWPass();
tmp = eLogPage->getLoTWPass();
if (tmp.length()>0)
{
stream << "LoTWPass=" << tmp << ";" << endl;
}
// LOTW
//qDebug() << "SetupDialog::slotOkButtonClicked - 70" << endl;
//WSJTX
stream << "UDPServer=" << UDPPage->getUDPServer() << ";" << endl;
stream << "UDPServerPort=" << UDPPage->getUDPServerPort() << ";" << endl;
@ -697,10 +740,10 @@ void SetupDialog::slotOkButtonClicked()
}
file.close ();
}
//qDebug() << "SetupDialog::slotOkButtonClicked - just before leaving" << endl;
//qDebug() << "SetupDialog::slotOkButtonClicked - just before leaving" << endl;
QDialog::accept();
emit debugLog (Q_FUNC_INFO, "END", logSeverity);
//qDebug() << "SetupDialog::slotOkButtonClicked - END" << endl;
//qDebug() << "SetupDialog::slotOkButtonClicked - END" << endl;
//close();
}
@ -1058,50 +1101,54 @@ bool SetupDialog::processConfigLine(const QString &_line)
//qDebug() << "SetupDialog::processConfigLine: dataProxy->doesThisLogExist END" << endl;
}else if(tab =="CLUBLOGACTIVE"){
clubLogPage->setClubLog(value);
eLogPage->setClubLogActive(value);
//clubLogPage->setClubLog(value);
}
else if(tab =="CLUBLOGREALTIME"){
clubLogPage->setClubLogRealTime(value);
//clubLogPage->setClubLogRealTime(value);
eLogPage->setClubLogRealTime(value);
}
//else if(tab =="CLUBLOGCALL"){
// clubLogPage->setCallsign(value);
//}
else if(tab =="CLUBLOGPASS"){
clubLogPage->setPassword(value);
//clubLogPage->setPassword(value);
eLogPage->setClubLogPassword(value);
}
else if(tab =="CLUBLOGEMAIL"){
clubLogPage->setEmail(value);
//clubLogPage->setEmail(value);
eLogPage->setClubLogEmail(value);
}
//else if(tab =="CLUBLOGUSESTATIONCALLSIGN"){
// clubLogPage->setUseStationCall(value);
//}
else if(tab =="EQSLACTIVE"){
eQSLPage->setActive(value);
//eQSLPage->setActive(value);
eLogPage->setEQSLActive(value);
}
/*
else if(tab =="EQSLREALTIME"){
eQSLPage->setRealTime(value);
//eQSLPage->setRealTime(value);
eLogPage->setEQSLRealTime(value);
}
*/
else if(tab =="EQSLCALL"){
eQSLPage->setCallsign(value);
//eQSLPage->setCallsign(value);
eLogPage->setEQSLEmail(value);
}
else if(tab =="EQSLPASS"){
eQSLPage->setPassword(value);
}
else if(tab =="EQSLUSESTATIONCALLSIGN"){
eQSLPage->setUseStationCall(value);
}
//eQSLPage->setPassword(value);
eLogPage->setEQSLPassword(value);
}
else if(tab =="LOTWACTIVE"){
lotwPage->setLoTW(value);
//lotwPage->setLoTW(value);
eLogPage->setLoTWActive(value);
}
else if(tab =="LOTWPATH"){
lotwPage->setPath(value);
//lotwPage->setPath(value);
eLogPage->setTQSLPath(value);
}
else if(tab =="LOTWUSER"){
lotwPage->setLoTWUser(value);
//lotwPage->setLoTWUser(value);
eLogPage->setLoTWUser(value);
}
else if(tab =="LOTWPASS"){
lotwPage->setLoTWPass(value);
//lotwPage->setLoTWPass(value);
eLogPage->setLoTWPass(value);
}
else if(tab =="MAINWINDOWSIZE"){
QStringList values;
@ -1312,11 +1359,13 @@ void SetupDialog::setClubLogActive(const bool _b)
emit debugLog (Q_FUNC_INFO, "Start", logSeverity);
if (_b == true)
{
clubLogPage->setClubLog("True");
eLogPage->setClubLogActive("True");
//clubLogPage->setClubLog("True");
}
else
{
clubLogPage->setClubLog("False");
eLogPage->setClubLogActive("False");
//clubLogPage->setClubLog("False");
}
emit debugLog (Q_FUNC_INFO, "END", logSeverity);
}

View File

@ -35,9 +35,10 @@
#include "setuppages/setuppagecolors.h"
#include "setuppages/setuppagelogs.h"
#include "setuppages/setuppageworldeditor.h"
#include "setuppages/setuppageclublog.h"
#include "setuppages/setuppageeqsl.h"
#include "setuppages/setuppagelotw.h"
//#include "setuppages/setuppageclublog.h"
#include "setuppages/setuppageelog.h"
//#include "setuppages/setuppageeqsl.h"
//#include "setuppages/setuppagelotw.h"
#include "setuppages/setuppageudp.h"
#include "setuppages/setuppagesats.h"
#include "setuppages/setuppagehamlib.h"
@ -123,9 +124,10 @@ private:
SetupPageColors *colorsPage;
SetupPageLogs *logsPage;
SetupPageWorldEditor *worldEditorPage;
SetupPageClubLog *clubLogPage;
SetupPageEQSL *eQSLPage;
SetupPageLoTW *lotwPage;
SetupPageELog *eLogPage;
//SetupPageClubLog *clubLogPage;
//SetupPageEQSL *eQSLPage;
//SetupPageLoTW *lotwPage;
SetupPageUDP *UDPPage;
SetupPageSats *satsPage;
SetupPageHamLib *hamlibPage;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -385,7 +385,26 @@ QString Utilities::getSaveSpotsLogFile()
QString filename = "/" + (QDateTime::currentDateTime()).toString("yyyyMMdd") + "-klogdxcluster.txt";
return getHomeDir() + filename;
}
QString Utilities::getBackupADIFile()
{
return getHomeDir() + (QDateTime::currentDateTime()).toString("yyyyMMdd-hhmm") + "-klogbackup.adi";
}
QString Utilities::getClubLogFile()
{
return getHomeDir() + "/klog-clublog-upload.adi";
}
QString Utilities::getEQSLFile()
{
return getHomeDir() + "/klog-eqsl-upload.adi";
}
QString Utilities::getLoTWAdifFile()
{
return getHomeDir() + "/klog-lotw-upload.adi";
}
QString Utilities::getTQSLsFileName()

View File

@ -37,7 +37,7 @@
#include "locator.h"
#include <QtDebug>
enum ExportMode {ModeLotW, ModeADIF, ModeClubLog};
enum ExportMode {ModeLotW, ModeADIF, ModeClubLog, ModeEQSL};
class Utilities
{
@ -64,6 +64,10 @@ public:
QString getCTYFile();
QString getDebugLogFile();
QString getSaveSpotsLogFile();
QString getBackupADIFile();
QString getClubLogFile();
QString getEQSLFile();
QString getLoTWAdifFile();
void setVersion(const QString &_v);
QString getVersion();

View File

@ -105,7 +105,7 @@ void AdifLoTWExportWidget::fillTable()
//qDebug() << "AdifLoTWExportWidget::fillTable " << endl;
QList<int> qsos;
qsos.clear();
bool justQueued;
bool justQueued = true;
switch (currentExportMode)
{
case ModeADIF:
@ -119,7 +119,12 @@ void AdifLoTWExportWidget::fillTable()
break;
case ModeClubLog:
//qDebug() << "AdifLoTWExportWidget::fillTable ClubLog" << endl;
//justQueued = false;
//justQueued = true;
break;
case ModeEQSL:
//qDebug() << "AdifLoTWExportWidget::fillTable EQSL" << endl;
justQueued = true;
break;
}
@ -138,11 +143,14 @@ void AdifLoTWExportWidget::fillTable()
{
qsos.append(dataProxy->getQSOsListClubLogToSent(stationCallsignComboBox->currentText(), startDate->date(), endDate->date(), true));
}
else if (currentExportMode == ModeEQSL)
{
qsos.append(dataProxy->getQSOsListEQSLToSent(stationCallsignComboBox->currentText(), startDate->date(), endDate->date(), true));
}
else
{
qsos.append(dataProxy->getQSOsListLoTWNotSent(stationCallsignComboBox->currentText(), startDate->date(), endDate->date(), justQueued));
}
}
//qsos.append(dataProxy->getQSOsListLoTWNotSent(stationCallsignComboBox->currentText(), startDate->date(), endDate->date(), true));
//qDebug() << "AdifLoTWExportWidget::fillTable QSOS: " << QString::number(qsos.length()) << endl;
@ -159,7 +167,6 @@ void AdifLoTWExportWidget::fillTable()
//qDebug() << "AdifLoTWExportWidget::fillTable in FOR " << QString::number(i) << endl;
addQSO(qsos.at(i));
}
}
numberLabel->setText(tr("QSOs: ") + QString::number(qsos.count()));
@ -167,7 +174,6 @@ void AdifLoTWExportWidget::fillTable()
{
//qDebug() << "AdifLoTWExportWidget::fillTable Enable OKButton" << endl;
okButton->setEnabled(true);
}
else
{
@ -240,7 +246,7 @@ void AdifLoTWExportWidget::slotOKPushButtonClicked()
}
else if (stationCallsignComboBox->currentIndex() == 1)
{
if ((currentExportMode == ModeLotW) || (currentExportMode == ModeClubLog))
if ((currentExportMode == ModeLotW) || (currentExportMode == ModeClubLog) || (currentExportMode == ModeEQSL))
{
emit selection(stationCallsignComboBox->currentText(), startDate->date(), endDate->date(), currentExportMode);
}
@ -248,7 +254,6 @@ void AdifLoTWExportWidget::slotOKPushButtonClicked()
{
emit selection("ALL", startDate->date(), endDate->date(), currentExportMode);
}
}
else
{
@ -296,6 +301,11 @@ void AdifLoTWExportWidget::setExportMode(const ExportMode _EMode)
setWindowTitle(tr("KLog - QSOs to be uploaded to ClubLog."));
topLabel->setText(tr("This table shows the QSOs that will be sent to ClubLog."));
}
else if (currentExportMode == ModeEQSL)
{
setWindowTitle(tr("KLog - QSOs to be uploaded to eQSL.cc."));
topLabel->setText(tr("This table shows the QSOs that will be sent to eQSL.cc."));
}
else
{
setWindowTitle("KLog - QSOs to be exported to ADIF.");

View File

@ -35,7 +35,6 @@ private:
void addQSO(const int _qsoID);
void fillStationCallsignComboBox();
DataProxy_SQLite *dataProxy;
QComboBox *stationCallsignComboBox;
QDateEdit *startDate, *endDate;

View File

@ -442,6 +442,13 @@ int World::getPrefixId(const QString &_qrz)
while ((entityID <= 0) && (aux.length()>=1) )
{
//qDebug() << "World::getPrefixId: in the while before calling dataProxy: " << aux << endl;
if (aux == "KG4")
{
if (_qrz.length()!=5)
{
aux = "K";
}
}
entityID = dataProxy->getDXCCFromPrefix(aux);
//qDebug() << "World::getPrefixId: in the while After calling dataProxy" << endl;