klog-1.8.6/ 0000755 0001750 0001750 00000000000 14166020421 011436 5 ustar devel devel klog-1.8.6/updatesatsdata.h 0000644 0001750 0001750 00000004501 14166020407 014622 0 ustar devel devel #ifndef UPDATESATSDATA_H
#define UPDATESATSDATA_H
/***************************************************************************
updatesatsdata.h - description
-------------------
begin : sep 2018
copyright : (C) 2018 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
#include
#include
#include
#include
#include "utilities.h"
#include "dataproxy_sqlite.h"
#include "dataproxy_sqlite.h"
class UpdateSatsData : public QObject
{
Q_OBJECT
public:
explicit UpdateSatsData(DataProxy_SQLite *dp, QObject *parent = nullptr);
bool readSatDataFile();
bool satDataFileRead(const QString& tfileName);
private:
Utilities *util;
DataProxy_SQLite *dataProxy;
signals:
void satsUpdatedSignal(const bool _p);
// void clearError();
public slots:
};
#endif // UPDATESATSDATA_H
klog-1.8.6/logwindow.h 0000644 0001750 0001750 00000015001 14166020407 013621 0 ustar devel devel #ifndef LOGWINDOW_H
#define LOGWINDOW_H
/***************************************************************************
logwindow.h - description
-------------------
begin : sept 2011
copyright : (C) 2011 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
#include
#include
//#include
#include
#include
#include
#include
#include
#include
#include "dataproxy_sqlite.h"
#include "logmodel.h"
#include "awards.h"
//#include "dxccstatuswidget.h"
//#include "elogclublog.h"
#include "utilities.h"
//#include "logviewsortfilterproxymodel.h"
//class LogViewSortFilterProxyModel;
//class ItemDelegate;
class LogWindow : public QWidget
{
Q_OBJECT
public:
explicit LogWindow(DataProxy_SQLite *dp, QWidget *parent = nullptr);
~LogWindow();
void createlogPanel(const int _currentLog);
void clear();
void refresh();
void setCurrentLog(const int _currentLog);
void qslSentViaBureau(const int _qsoId); //Maybe this could be defined as private and call it with an action, if needed.
void qslRecViaBureau(const int _qsoId); //Maybe this could be defined as private and call it with an action, if needed.
void qslRecViaDirect(const int _qsoId);
bool isQSLReceived(const int _qsoId);
bool isQSLSent(const int _qsoId);
//void setProxyModel (const bool _p);
void sortColumn(const int _c);
void setColumns(const QStringList &_columns);
signals:
void actionQSODoubleClicked(const int _qsoid);
void actionDeleteQSO(const int _qsoid);
void updateAwards();
void updateSearchText();
//void qsoFound(const QStringList _qs); // Each: QString with format: Fieldname:value
void queryError(QString functionFailed, QString errorCodeS, QString nativeError, QString failedQuery); // To alert about any failed query execution
//void clearError();
void deleteTheseQSOs(QList _qsos);
void exportToADIFTheseQSOs(QList _qsos);
void uploadToQRZcomTheseQSOs(QList _qsos);
private slots:
void slotDoubleClickLog(const QModelIndex & index);
void slotRighButtonFromLog(const QPoint& pos);
void slotQSLSentViaBureauFromLog();
void slotQSLSentViaDirectFromLog();
void slotQSLRecViaDirectFromLog();
void slotQSLRecViaBureauFromLog();
void slotQsoDeleteFromLog();
void slotQSOToEditFromLog();
void slotQueryErrorManagement(QString functionFailed, QString errorCodeS, QString nativeError, QString failedQuery);
void slotCheckQRZCom();
void slotCheckDXHeatCom();
void slotQSOsDeselectAll();
void slotQSOsSelectAll();
void slotQSOsDeleteFromLog();
void slotQSOsExportFromLog();
void slotQSOsUploadToLoTWFromLog();
void slotQSOsUploadToClubLogFromLog();
void slotQSOsUploadToEQSLFromLog();
void slotMultipleQSLSentViaBureauFromLog();
void slotMultipleQSLSentViaDirectFromLog();
void slotMultipleQSLRecViaBureauFromLog();
void slotMultipleQSLRecViaDirectFromLog();
void slotQSOsQRZUploadFromLog();
private:
void createUI();
void createActionsCommon();
void createActions();
void deleteQSO(const int _qsoID);
void rightButtonFromLogMenu(const int trow);
void rightButtonMultipleFromLogMenu();
void showMenuRightButtonFromLogCreateActions();
void showColumn(const QString &_columnName);
void setDefaultData();
void setColumnsOfLog(const QStringList &_columns);
DataProxy_SQLite *dataProxy;
LogModel *logModel;
//QItemSelectionModel *selectionModel;
Awards *awards;
//DXCCStatusWidget *dxccStatusWidget;
//eLogClubLog *elogClublog;
QTableView *logView;
QLabel *logLabel;
QAction *delQSOFromLogAct;
QAction *qsoToEditFromLogAct;
QAction *qslSentViaBureauFromLogAct;
QAction *qslSentViaDirectFromLogAct;
QAction *qslRecViaBureauFromLogAct;
QAction *qslRecViaDirectFromLogAct;
QAction *checkQRZCOMFromLogAct;
QAction *checkDXHeatFromLogAct;
//Multiple selection actions
QAction *multipleDeselectAll;
QAction *multipleSelectAll;
QAction *multipleDelQSOsFromLogAct;
QAction *multipleExportToADIFFromLogAct;
QAction *multipleQueueForLoTWFromLogAct;
QAction *multipleQueueForClubLogFromLogAct;
QAction *multipleQueueForQRZCOMFromLogAct;
QAction *multipleQueueForEQSLFromLogAct;
QAction *multipleQslSentViaBureauFromLogAct;
QAction *multipleQslSentViaDirectFromLogAct;
QAction *multipleQslRecViaBureauFromLogAct;
QAction *multipleQslRecViaDirectFromLogAct;
//QAction *moveToAnotherLog; // MOves the selected QSOs to another log.
int currentLog;
Utilities *util;
QStringList columns;
//LogViewSortFilterProxyModel *proxyModel;
//bool sortingThroughProxyModel;
};
/*
class ItemDelegate: public QStyledItemDelegate
{
Q_OBJECT
public:
ItemDelegate(QWidget *parent=nullptr){}
QString displayText(const QVariant &value, const QLocale &locale) const;
//QString displayText (const QVariant &value);
};
*/
#endif // LOGWINDOW_H
klog-1.8.6/dataproxy_sqlite.cpp 0000644 0001750 0001750 00001170771 14166020421 015554 0 ustar devel devel /***************************************************************************
dataproxy_sqlite.cpp - description
-------------------
begin : sept 2014
copyright : (C) 2014 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
#include "dataproxy_sqlite.h"
#include "utilities.h"
//#include
DataProxy_SQLite::DataProxy_SQLite(const QString &_parentFunction, const QString &_softVersion)
{
#ifdef QT_DEBUG
//qDebug() << Q_FUNC_INFO << _softVersion << _parentFunction << QT_ENDL;
#else
//qDebug() << Q_FUNC_INFO << "Running a release build";
#endif
//qDebug() << "DataProxy_SQLite::DataProxy_SQLite" << _softVersion << _parentFunction << QT_ENDL;
//qDebug() << "DataProxy_SQLite::DataProxy_SQLite 1" << QT_ENDL;
util = new Utilities();
util->setVersion(_softVersion);
qso = new QSO;
db = new DataBase(Q_FUNC_INFO, _softVersion, util->getKLogDBFile());
dbCreated = db->createConnection(Q_FUNC_INFO);
//dbCreated = db->createBandModeMaps();
//qDebug() << "DataProxy_SQLite::DataProxy_SQLite - END" << QT_ENDL;
searching = false;
executionN = 0;
//preparedQuery = new QSqlQuery;
//db = new DataBase(0);
//DataProxy_SQLite = new DataProxy_SQLite();
//qDebug() << "DataProxy_SQLite::DataProxy_SQLite END" << QT_ENDL;
//connect(db, SIGNAL(debugLog(QString, QString, int)), this, SLOT(slotCaptureDebugLogs(QString, QString, int)) );
}
DataProxy_SQLite::~DataProxy_SQLite()
{
delete(util);
delete(qso);
//qDebug() << "DataProxy_SQLite::~DataProxy_SQLite" << QT_ENDL;
}
int DataProxy_SQLite::getHowManyQSOPerPropMode(const QString &_p, const int _logn)
{
//qDebug() << "DataProxy_SQLite::getHowManyQSOPerPropMode: " << _p << "/" << QString::number(_logn) << QT_ENDL;
QSqlQuery query;
QString queryString;
bool sqlOK;
if (_logn < 0)
{
queryString = QString("SELECT COUNT (DISTINCT id) FROM log WHERE prop_mode='%1'").arg(_p);
}
else
{
queryString = QString("SELECT COUNT (DISTINCT id) FROM log where lognumber='%1' AND prop_mode='%2'").arg(_logn).arg(_p);
}
sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::getHowManyQSOPerPropMode: queryString: " << queryString << QT_ENDL;
if (sqlOK)
{
query.next();
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::getHowManyQSOPerPropMode: " << QString::number((query.value(0)).toInt()) << QT_ENDL;
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
//qDebug() << "DataProxy_SQLite::getHowManyQSOPerPropModer: 0" << QT_ENDL;
query.finish();
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::getHowManyQSOPerPropMode: Query error" << QT_ENDL;
query.finish();
return 0;
}
}
QString DataProxy_SQLite::getSoftVersion()
{ //SELECT MAX (softversion) FROM softwarecontrol
QSqlQuery query;
QString stQuery = QString("SELECT MAX (softversion) FROM softwarecontrol");
if (query.exec(stQuery))
{
query.next();
if (query.isValid())
{
QString v = (query.value(0)).toString();
query.finish();
//qDebug() << "DataProxy_SQLite::getSoftVersion: DATA: " << v << QT_ENDL;
if (v.length()<1)
{
//The following is not a query error but if the softwareversion value is lower than 0 or empty
queryError(Q_FUNC_INFO, tr("Software version in DB is null"), "-1", tr("Query didn't failed")); // To alert about any failed query execution
}
return v;
}
else
{
query.finish();
//qDebug() << "DataProxy_SQLite::getSoftVersion: version empty-1" << QT_ENDL;
return QString();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
//qDebug() << "DataProxy_SQLite::getSoftVersion: version empty-1 - ERROR" << QT_ENDL;
return QString();
}
}
QString DataProxy_SQLite::getDBVersion()
{ //SELECT MAX (dbversion) FROM softwarecontrol
QSqlQuery query;
QString stQuery = QString("SELECT MAX (dbversion) FROM softwarecontrol");
if (query.exec(stQuery))
{
query.next();
if (query.isValid())
{
QString v = (query.value(0)).toString();
query.finish();
return v;
}
else
{
query.finish();
return QString();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
}
bool DataProxy_SQLite::reconnectDB()
{
return db->reConnect(util->getKLogDBFile());
}
void DataProxy_SQLite::createLogModel()
{
//qDebug() << "DataProxy_SQLite::createLogModel" << QT_ENDL;
}
void DataProxy_SQLite::createLogPanel(){
//qDebug() << "DataProxy_SQLite::createLogPanel" << QT_ENDL;
}
int DataProxy_SQLite::getIdFromModeName(const QString& _modeName)
{
//qDebug() << "DataProxy_SQLite::getIdFromModeName: " << _modeName << "/" << QString::number(db->getModeIDFromName2(_modeName)) << QT_ENDL;
if (_modeName.length()<2)
{
return -4;
}
return db->getModeIDFromName2(_modeName);
}
int DataProxy_SQLite::getSubModeIdFromSubMode(const QString &_subModeName)
{
//qDebug() << "DataProxy_SQLite::getSubModeIdFromSubMode: " << _subModeName << QT_ENDL;
if (_subModeName.length()<2)
{
return -3;
}
QSqlQuery query;
QString stQuery = QString("SELECT id FROM mode WHERE submode='%1'").arg(_subModeName.toUpper());
if (query.exec(stQuery))
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -2;
}
}
int DataProxy_SQLite::getModeIdFromSubModeId(const int _sm)
{
return getIdFromModeName(getNameFromSubMode(getSubModeFromId(_sm)));
}
bool DataProxy_SQLite::isModeDeprecated (const QString &_sm)
{
if (_sm.length()<2)
{
return -3;
}
QSqlQuery query;
QString stQuery = QString("SELECT deprecated FROM mode WHERE submode='%1'").arg(_sm);
if (query.exec(stQuery))
{
query.next();
if (query.isValid())
{
if ( (query.value(0)).toInt() == 1 )
{
query.finish();
return true;
}
else
{
query.finish();
return false;
}
}
else
{
query.finish();
return false; // In case we can't check, we don't state it as deprecated
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false; // In case we can't check, we don't state it as deprecated
}
}
int DataProxy_SQLite::getIdFromBandName(const QString& _bandName)
{
//qDebug() << "DataProxy_SQLite::getIdFromBandName: " << _bandName << "/" << QString::number(db->getBandIDFromName2(_bandName))<< QT_ENDL;
if (_bandName.length()<1)
{
//qDebug() << "DataProxy_SQLite::getIdFromBandName:-4: " << _bandName << "/" << QString::number(db->getBandIDFromName2(_bandName))<< QT_ENDL;
return -4;
}
return db->getBandIDFromName2(_bandName);
}
QString DataProxy_SQLite::getNameFromBandId (const int _id)
{
//qDebug() << "DataProxy_SQLite::getNameFromBandId: " << QString::number(_id) << QT_ENDL;
return db->getBandNameFromID2(_id);
}
QString DataProxy_SQLite::getNameFromModeId (const int _id)
{
//qDebug() << "DataProxy_SQLite::getNameFromModeId" << QT_ENDL;
//return db->getModeNameFromID2(_id);
return db->getModeNameFromNumber(_id);
}
QString DataProxy_SQLite::getNameFromSubModeId (const int _id)
{
//qDebug() << "DataProxy_SQLite::getNameFromSubModeId: " << QString::number(_id) << "DB: " << db->getModeNameFromID2(_id) << QT_ENDL;
return db->getSubModeNameFromID2(_id);
/*
QSqlQuery query;
QString queryString = QString("SELECT submode, name, deprecated FROM mode WHERE id='%1'").arg(_id);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
if ( (query.value(2)).toInt()<0 )
{ // DEPRECATED VALUE, return the MODE
return (query.value(1)).toString();
}
else
{
return (query.value(0)).toString();
}
}
else
{
return QString();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
return QString();
}
*/
}
QString DataProxy_SQLite::getSubModeFromId (const int _id)
{
//qDebug() << "DataProxy_SQLite::getSubModeFromId: " << QString::number(_id) << QT_ENDL;
QSqlQuery query;
QString queryString = QString("SELECT submode FROM mode WHERE id='%1'").arg(_id);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
QString v = (query.value(0)).toString();
query.finish();
return v;
}
else
{
query.finish();
return QString();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
}
QString DataProxy_SQLite::getNameFromSubMode (const QString &_sm)
{
QSqlQuery query;
QString queryString = QString("SELECT name FROM mode WHERE submode='%1'").arg(_sm.toUpper());
//QString queryString = QString("SELECT name, deprecated FROM mode WHERE submode='%1'").arg(_sm.toUpper());
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
QString v = (query.value(0)).toString();
query.finish();
return v;
}
else
{
query.finish();
return QString();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
}
QString DataProxy_SQLite::getFreqFromBandId(const int _id)
{
//qDebug() << "DataProxy_SQLite::getFreqFromBandId: " << QString::number(_id) << QT_ENDL;
return db->getFreqFromBandId(_id);
}
int DataProxy_SQLite::getBandIdFromFreq(const double _n)
{
//qDebug() << "DataProxy_SQLite::getBandIdFromFreq: " << QString::number(_n) << QT_ENDL;
//Freq should be in MHz
bool sqlOk = false;
QString queryString = QString("SELECT id FROM band WHERE lower <= '%1' and upper >= '%2'").arg(_n).arg(_n);
QSqlQuery query(queryString);
sqlOk = query.exec();
//qDebug() << "DataProxy_SQLite::getBandIdFromFreq: Query: " << query.lastQuery() << QT_ENDL;
if (sqlOk)
{
//qDebug() << "DataProxy_SQLite::getBandIdFromFreq: Query OK" << QT_ENDL;
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
//qDebug() << "DataProxy_SQLite::getBandIdFromFreq: Query NOK" << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -2;
}
//return -3;
}
QString DataProxy_SQLite::getBandNameFromFreq(const double _n)
{
//qDebug() << "DataProxy_SQLite::getBandNameFromFreq: " << QString::number(_n) << QT_ENDL;
return getNameFromBandId(getBandIdFromFreq(_n));
}
double DataProxy_SQLite::getLowLimitBandFromBandName(const QString &_sm)
{
//qDebug() << "DataProxy_SQLite::getLowLimitBandFromBandName: " << _sm << QT_ENDL;
if (_sm.length ()<2)
{
//qDebug() << "DataProxy_SQLite::getLowLimitBandFromBandName: length <2" << QT_ENDL;
return -1.0;
}
QSqlQuery query;
QString queryString = QString("SELECT lower FROM band WHERE name='%1' OR name='%2'").arg(_sm).arg(_sm.toUpper());
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
double fr = (query.value(0)).toDouble();
query.finish();
if ( fr < 0 )
{
//qDebug() << "DataProxy_SQLite::getLowLimitBandFromBandName: -1.0-1" << QT_ENDL;
return -1.0;
}
else
{
//qDebug() << "DataProxy_SQLite::getLowLimitBandFromBandName(value found): " << QString::number(fr) << QT_ENDL;
return fr;
}
}
else
{
//qDebug() << "DataProxy_SQLite::getLowLimitBandFromBandName: -1.0-2" << QT_ENDL;
query.finish();
return -1.0;
}
//qDebug() << "DataProxy_SQLite::getLowLimitBandFromBandName: -1.0-3" << QT_ENDL;
}
else
{
//qDebug() << "DataProxy_SQLite::getLowLimitBandFromBandName: SQL Error" << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1.0;
}
//qDebug() << "DataProxy_SQLite::getLowLimitBandFromBandName: -1.0-5" << QT_ENDL;
}
double DataProxy_SQLite::getLowLimitBandFromBandId(const int _sm)
{
//qDebug() << "DataProxy_SQLite::getLowLimitBandFromBandId" << QT_ENDL;
QSqlQuery query;
QString queryString = QString("SELECT lower FROM band WHERE id='%1'").arg(_sm);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
if ( (query.value(1)).toDouble()<0 )
{
//qDebug() << "DataProxy_SQLite::getLowLimitBandFromBandId: -1.0-1" << QT_ENDL;
query.finish();
return -1.0;
}
else
{
//qDebug() << "DataProxy_SQLite::getLowLimitBandFromBandId: " << QString::number((query.value(0)).toDouble()) << QT_ENDL;
double v = (query.value(0)).toDouble();
query.finish();
return v;
}
}
else
{
//qDebug() << "DataProxy_SQLite::getLowLimitBandFromBandId: -1.0-2" << QT_ENDL;
query.finish();
return -1.0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1.0;
}
}
double DataProxy_SQLite::getUpperLimitBandFromBandName(const QString &_sm)
{
//qDebug() << Q_FUNC_INFO << ": " << _sm << QT_ENDL;
if (_sm.length ()<2)
{
return -1.0;
}
QSqlQuery query;
QString queryString = QString("SELECT upper FROM band WHERE name='%1' OR name='%2'").arg(_sm).arg(_sm.toUpper());
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
if ( (query.value(0)).toDouble()<0 )
{
//qDebug() << Q_FUNC_INFO << ": -1.0-1" << QT_ENDL;
query.finish();
return -1.0;
}
else
{
//qDebug() << Q_FUNC_INFO << ": (else): " << QString::number((query.value(0)).toDouble()) << QT_ENDL;
double v = (query.value(0)).toDouble();
query.finish();
return v;
}
}
else
{
//qDebug() << Q_FUNC_INFO << ": -1.0-2" << QT_ENDL;
query.finish();
return -1.0;
}
//qDebug() << Q_FUNC_INFO << ": -1.0-3" << QT_ENDL;
//query.finish();
//return -1.0;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1.0;
}
//return -1.0;
}
bool DataProxy_SQLite::isThisFreqInBand(const QString &_band, const QString &_fr)
{
return db->isThisFreqInBand(_band, _fr);
}
QStringList DataProxy_SQLite::getFields()
{
//qDebug() << Q_FUNC_INFO;
QStringList fields;
fields.clear();
QSqlQuery q;
QSqlRecord localRecord = q.driver()->record("log");
for (int var = 0; var < localRecord.count(); ++var) {
QString fieldName = localRecord.fieldName(var);
fields << fieldName;
//qDebug() << fieldName;
}
/*
QString LogWindow::getColumnName(int col)
{
return logModel->record().fieldName(col);
}
*/
return fields;
}
QStringList DataProxy_SQLite::getBands()
{
//qDebug() << "DataProxy_SQLite::getBands - DEPRECATED please use getBandNames - TODO: Remove this function and change the calls" << QT_ENDL;
return getBandNames();
/*
QStringList bands = QStringList();
QSqlQuery query("SELECT name FROM band");
while (query.next()) {
if (query.isValid()){
bands << query.value(0).toString();
}
}
//return bands;
return sortBandNamesBottonUp(bands);
*/
}
QStringList DataProxy_SQLite::getBandNames()
{
//qDebug() << "DataProxy_SQLite::getBandNames" << QT_ENDL;
QStringList bands = QStringList();
QSqlQuery query;
QString queryString;
bool sqlOK;
queryString = QString("SELECT DISTINCT name FROM band");
sqlOK = query.exec(queryString);
if (sqlOK)
{
while(query.next())
{
if (query.isValid())
{
queryString = (query.value(0)).toString();
//qDebug() << "DataProxy_SQLite::getBandNames: " << queryString << QT_ENDL;
bands.append(queryString);
}
else
{
query.finish();
return QStringList();
}
}
query.finish();
return sortBandNamesBottonUp(bands);
//return bands;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QStringList();
}
}
QStringList DataProxy_SQLite::getModes()
{
QStringList modes = QStringList();
QSqlQuery query("SELECT submode FROM mode ORDER BY submode");
while (query.next()) {
if (query.isValid()){
modes << query.value(0).toString();
}
}
query.finish();
modes.sort();
return modes;
}
QStringList DataProxy_SQLite::sortBandNamesBottonUp(const QStringList _qs)
{
//Receives a list of band names, sorts it from the lower band to the upper band and returns
//qDebug() << "DataProxy_SQLite::sortBandNamesBottonUp: " << QString::number(_qs.length()) << QT_ENDL;
if (_qs.length()<2)
{
return _qs;
}
QMap map;
map.clear();
QStringList qs;
qs.clear();
//qDebug() << "DataProxy_SQLite::sortBandNamesBottonUp-00" << QT_ENDL;
for (int j=0; j<_qs.count(); j++)
{
map.insert(getLowLimitBandFromBandName(_qs.at(j)), _qs.at(j));
}
//qDebug() << "DataProxy_SQLite::sortBandNamesBottonUp-10" << QT_ENDL;
QMap::const_iterator i = map.constBegin();
//qDebug() << "DataProxy_SQLite::sortBandNamesBottonUp-20" << QT_ENDL;
while (i != map.constEnd()) {
qs << i.value();
++i;
}
//qDebug() << "DataProxy_SQLite::sortBandNamesBottonUp - END -lengh = " << QString::number(qs.length()) << QT_ENDL;
qs.removeDuplicates();
return qs;
}
QStringList DataProxy_SQLite::getBandIDs()
{
//qDebug() << "DataProxy_SQLite::getBandIDs" << QT_ENDL;
QStringList bands = QStringList();
QSqlQuery query("SELECT id FROM band");
while (query.next()) {
if (query.isValid()){
bands << query.value(0).toString();
}
}
query.finish();
return sortBandIdBottonUp(bands);
}
QStringList DataProxy_SQLite::sortBandIdBottonUp(const QStringList _qs)
{
//Receives a list of band id, sorts it from the lower band to the upper band and returns
QMap map;
QStringList qs;
qs.clear();
for (int j=0; j<_qs.count(); j++)
{
map.insert(getLowLimitBandFromBandId(_qs.at(j).toInt()), _qs.at(j));
}
QMap::const_iterator i = map.constBegin();
while (i != map.constEnd()) {
qs << i.value();
++i;
}
return qs;
}
QStringList DataProxy_SQLite::getModesIDs()
{
QStringList modes = QStringList();
QSqlQuery query("SELECT id FROM mode");
while (query.next()) {
if (query.isValid()){
modes << query.value(0).toString();
}
}
query.finish();
return modes;
}
QStringList DataProxy_SQLite::getBandsInLog(const int _log)
{
//qDebug() << "DataProxy_SQLite::getBandsInLog: " << QT_ENDL;
QStringList bands = QStringList();
QString queryString = QString();
if (_log <= 0)
{
queryString = QString("SELECT DISTINCT band.name FROM log, band WHERE band.id = log.bandid ORDER BY band.id DESC");
}
else
{
queryString = QString("SELECT DISTINCT band.name FROM log, band WHERE band.id = log.bandid AND log.lognumber='%1' ORDER BY band.id DESC").arg(_log);
}
QSqlQuery query(queryString);
while (query.next()) {
if (query.isValid()){
bands << query.value(0).toString();
}
}
query.finish();
return sortBandNamesBottonUp(bands);
//return bands;
}
QStringList DataProxy_SQLite::getModesInLog(const int _log)
{
//qDebug() << "DataProxy_SQLite::getModesInLog: " << QT_ENDL;
QStringList modes = QStringList();
QString queryString = QString();
if (_log <=0 )
{
queryString = QString("SELECT mode.id, mode.submode, COUNT (mode.submode) FROM log, mode WHERE mode.id = log.modeid GROUP BY mode.submode ORDER BY count (mode.submode) DESC");
}
else
{
queryString = QString("SELECT mode.id, mode.submode, COUNT (mode.submode) FROM log, mode WHERE mode.id = log.modeid AND log.lognumber='%1' GROUP BY mode.submode ORDER BY count (mode.submode) DESC").arg(_log);
}
QSqlQuery query(queryString);
while (query.next()) {
if (query.isValid()){
modes << query.value(1).toString();
}
}
query.finish();
//qDebug() << "DataProxy_SQLite::getModesInLog: " << modes.join(" - ") << QT_ENDL;
modes.sort();
return modes;
}
int DataProxy_SQLite::getMostUsedBand(const int _log)
{
//qDebug() << "DataProxy_SQLite::getMostUsedBand: " << QT_ENDL;
QString queryString = QString();
if (_log <=0 )
{
queryString = QString("SELECT band.id, band.name, COUNT (band.name) FROM log, band WHERE band.id = log.bandid GROUP BY band.id ORDER BY count (band.id) DESC LIMIT 1");
}
else
{
queryString = QString("SELECT band.id, band.name, COUNT (band.name) FROM log, band WHERE band.id = log.bandid AND log.lognumber='%1' GROUP BY band.id ORDER BY count (band.id) DESC LIMIT 1").arg(_log);
}
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
if (query.next())
{
if (query.isValid())
{
int v = query.value(0).toInt();
query.finish();
//qDebug() << "DataProxy_SQLite::getMostUsedBand-OK: " << QString::number(v)<< QT_ENDL;
return v;
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
//qDebug() << "DataProxy_SQLite::getMostUsedBand-ERROR-1: " << QT_ENDL;
return -1;
}
//qDebug() << "DataProxy_SQLite::getMostUsedBand-ERROR-2: " << QT_ENDL;
return -2;
}
int DataProxy_SQLite::getMostUsedMode(const int _log)
{
//qDebug() << "DataProxy_SQLite::getMostUsedMode: " << QT_ENDL;
QString queryString = QString();
if (_log <=0 )
{
queryString = QString("SELECT mode.id, mode.submode, COUNT (mode.submode) FROM log, mode WHERE mode.id = log.modeid GROUP BY mode.submode ORDER BY count (mode.submode) DESC LIMIT 1");
}
else
{
queryString = QString("SELECT mode.id, mode.submode, COUNT (mode.submode) FROM log, mode WHERE mode.id = log.modeid AND log.lognumber='%1' GROUP BY mode.submode ORDER BY count (mode.submode) DESC LIMIT 1").arg(_log);
}
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
if (query.next())
{
if (query.isValid())
{
int v = query.value(0).toInt();
query.finish();
return v;
}
}
query.finish();
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
return -2;
}
int DataProxy_SQLite::getLastQSOid()
{
//qDebug() << "DataProxy_SQLite::getLastQSOid" << QT_ENDL;
QSqlQuery query;
bool sqlOK = query.exec("SELECT MAX(id) from log");
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = query.value(0).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
}
QDate DataProxy_SQLite::getFirstQSODateFromCall (const QString &_call)
{
//qDebug() << "DataProxy_SQLite::getFirstQSODateFromCall: " << _call << QT_ENDL;
QSqlQuery query;
QString stringQuery;
QDate _date;
if (util->isValidCall(_call))
{
stringQuery = QString("SELECT qso_date from log where station_callsign='%1' ORDER BY qso_date ASC LIMIT 1").arg(_call);
}
else
{
stringQuery = QString("SELECT qso_date from log where 1 ORDER BY qso_date ASC LIMIT 1");
}
bool sqlOK = query.exec(stringQuery);
if (sqlOK)
{
query.next();
if (query.isValid())
{
_date = util->getDateFromSQliteString((query.value(0)).toString());
//_date = QDate::fromString((query.value(0)).toString(), "yyyy-MM-dd");
//stringQuery = query.value(0).toString();
query.finish();
if (_date.isValid())
{
//qDebug() << "DataProxy_SQLite::getFirstQSODateFromCall: END OK" << QT_ENDL;
return _date;
}
else
{
//qDebug() << "DataProxy_SQLite::getFirstQSODateFromCall: END-1 " << QT_ENDL;
return QDate();
}
}
else
{
query.finish();
//qDebug() << "DataProxy_SQLite::getFirstQSODateFromCall: END-2" << QT_ENDL;
return QDate();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
//qDebug() << "DataProxy_SQLite::getFirstQSODateFromCall: END-3" << QT_ENDL;
return QDate();
}
}
QDate DataProxy_SQLite::getLastQSODateFromCall (const QString &_call)
{
//qDebug() << "DataProxy_SQLite::getLastQSODateFromCall: " << _call << QT_ENDL;
QSqlQuery query;
QString stringQuery;
QDate _date;
if (util->isValidCall(_call))
{
stringQuery = QString("SELECT qso_date from log where station_callsign='%1' ORDER BY qso_date DESC LIMIT 1").arg(_call);
}
else
{
stringQuery = QString("SELECT qso_date from log where 1 ORDER BY qso_date DESC LIMIT 1");
}
bool sqlOK = query.exec(stringQuery);
if (sqlOK)
{
query.next();
if (query.isValid())
{
_date = util->getDateFromSQliteString((query.value(0)).toString());
//_date = QDate::fromString((query.value(0)).toString(), "yyyy-MM-dd");
//stringQuery = query.value(0).toString();
query.finish();
if (_date.isValid())
{
//qDebug() << "DataProxy_SQLite::getLastQSODateFromCall: OK" << QT_ENDL;
return _date;
}
else
{
//qDebug() << "DataProxy_SQLite::getLastQSODateFromCall: END-1" << QT_ENDL;
return QDate();
}
}
else
{
query.finish();
//qDebug() << "DataProxy_SQLite::getLastQSODateFromCall: END-2" << QT_ENDL;
return QDate();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
//qDebug() << "DataProxy_SQLite::getLastQSODateFromCall: END-3" << QT_ENDL;
return QDate();
}
}
bool DataProxy_SQLite::clearLog()
{
//qDebug() << "DataProxy_SQLite::clearLog" << QT_ENDL;
//int errorCode = 0;
QSqlQuery query;
bool sqlOK = query.exec("DELETE FROM log");
if (sqlOK)
{
//qDebug() << "DataProxy_SQLite::clearLog: Log deleted!" << QT_ENDL;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::clearLog: Log deleted FAILED" << QT_ENDL;
//errorCode = query.lastError().nativeErrorCode();
//qDebug() << "DataProxy_SQLite::clearLog: LastQuery: " << query.lastQuery() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog: LastError-data: " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog: LastError-driver: " << query.lastError().driverText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog: LastError-n: " << QString::number(query.lastError().nativeErrorCode() ) << QT_ENDL;
}
query.finish();
sqlOK = query.exec("DELETE FROM awarddxcc");
if (sqlOK)
{
//qDebug() << "DataProxy_SQLite::clearLog: Awarddxcc deleted!" << QT_ENDL;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::clearLog: Awarddxcc deletedFAILED" << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog - query error: " << QString::number(query.lastError().nativeErrorCode()) << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog: LastQuery: " << query.lastQuery() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog: LastError-data: " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog: LastError-driver: " << query.lastError().driverText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog: LastError-n: " << QString::number(query.lastError().nativeErrorCode() ) << QT_ENDL;
}
query.finish();
if (query.exec("DELETE FROM awardwaz"))
{
//qDebug() << "DataProxy_SQLite::clearLog: Awardwaz deleted!" << QT_ENDL;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::clearLog: Awardwaz deleted FAILED" << QT_ENDL;
//errorCode = query.lastError().nativeErrorCode();
//qDebug() << "DataProxy_SQLite::clearLog - query error: " << QString::number(query.lastError().nativeErrorCode()) << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog: LastQuery: " << query.lastQuery() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog: LastError-data: " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog: LastError-driver: " << query.lastError().driverText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog: LastError-n: " << QString::number(query.lastError().nativeErrorCode() ) << QT_ENDL;
}
query.finish();
//query.clear();
if (query.isActive())
{
//qDebug() << "DataProxy_SQLite::clearLog: Query Active!" << QT_ENDL;
query.finish();
return false;
}
else
{
query.prepare("VACUUM;");
//qDebug() << "DataProxy_SQLite::clearLog: Query Not Active!" << QT_ENDL;
if (query.exec())
{
//qDebug() << "DataProxy_SQLite::clearLog: VACUUM OK!" << QT_ENDL;
query.finish();
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::clearLog: VACUUM FAILED" << QT_ENDL;
//errorCode = query.lastError().nativeErrorCode();
//qDebug() << "DataProxy_SQLite::clearLog - query error: " << QString::number(query.lastError().nativeErrorCode()) << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog: LastQuery: " << query.lastQuery() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog: LastError-data: " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog: LastError-driver: " << query.lastError().driverText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::clearLog: LastError-n: " << QString::number(query.lastError().nativeErrorCode() ) << QT_ENDL;
}
}
query.finish();
return false;
}
bool DataProxy_SQLite::qslSentViaDirect(const int _qsoId, const QDate &_updateDate)
{
//qDebug() << "DataProxy_SQLite::qslSentViaDirect" << QT_ENDL;
QSqlQuery query;
QString queryString;
queryString = QString("UPDATE log SET qsl_sent = 'Y', qsl_sent_via = 'D', qslsdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
//qDebug() << "DataProxy_SQLite::qslSentViaDirect: " << queryString << QT_ENDL;
bool sqlOK = query.exec(queryString);
query.finish();
if (sqlOK)
{
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
return false;
}
bool DataProxy_SQLite::qslSentViaBureau(const int _qsoId, const QDate &_updateDate)
{
//qDebug() << "DataProxy_SQLite::qslSentViaBureau" << QT_ENDL;
QSqlQuery query;
QString queryString;
queryString = QString("UPDATE log SET qsl_sent = 'Y', qsl_sent_via = 'B', qslsdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
bool sqlOK = query.exec(queryString);
query.finish();
if (sqlOK)
{
//qDebug() << "DataProxy_SQLite::qslSentViaBureau - OK" << QT_ENDL;
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::qslSentViaBureau - NOK" << QT_ENDL;
}
return false;
}
bool DataProxy_SQLite::qslRecViaBureau(const int _qsoId, const QDate &_updateDate)
{
//qDebug() << "DataProxy_SQLite::" << QString::number (_qsoId) << "/" << _updateDate << QT_ENDL;
QSqlQuery query;
QString queryString;
queryString = QString("UPDATE log SET qsl_rcvd = 'Y', qsl_rcvd_via = 'B', qslrdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
bool sqlOK = query.exec(queryString);
query.finish();
if (sqlOK)
{
//qDebug() << "DataProxy_SQLite:: TRUE" << QT_ENDL;
//setDXCCAwardStatus(_qsoId);
//setWAZAwardStatus(_qsoId);
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
//qDebug() << "DataProxy_SQLite:: FALSE" << QT_ENDL;
return false;
}
bool DataProxy_SQLite::qslRecViaBureau(const int _qsoId, const QDate &_updateDate, const bool _queueSentQSL)
{
//qDebug() << "DataProxy_SQLite::qslRecViaBureau: " << _updateDate << QT_ENDL;
QSqlQuery query;
QString queryString;
//bool requestQSL = false;
bool sqlOK;
if (_queueSentQSL)
{
queryString = QString("SELECT qsl_sent FROM log WHERE id = '%1'").arg(_qsoId);
sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
queryString = (query.value(0)).toString();
if ((queryString == "Y") || (queryString == "R"))
{
// NO ACTION REQUIRED, QSL IS ALREADY SENT
//qDebug() << "DataProxy_SQLite::qslRecViaBureau: QSL already requested" << QT_ENDL;
//requestQSL = false;
queryString = QString("UPDATE log SET qsl_rcvd = 'Y', qsl_rcvd_via = 'B', qslrdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
}
else
{
//qDebug() << "DataProxy_SQLite::qslRecViaBureau: Request QSL-1" << QT_ENDL;
//requestQSL = true;
queryString = QString("UPDATE log SET qsl_rcvd = 'Y', qsl_rcvd_via = 'B', qsl_sent='R', qslrdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
}
}
else
{
//qDebug() << "DataProxy_SQLite::qslRecViaBureau: Request QSL-2" << QT_ENDL;
queryString = QString("UPDATE log SET qsl_rcvd = 'Y', qsl_rcvd_via = 'B', qsl_sent='R', qslrdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
//requestQSL = true;
}
}
else
{
//qDebug() << "DataProxy_SQLite::qslRecViaBureau: Request QSL-3" << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
queryString = QString("UPDATE log SET qsl_rcvd = 'Y', qsl_rcvd_via = 'B', qsl_sent='R', qslrdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
//requestQSL = true;
}
}
else
{
//requestQSL = false;
queryString = QString("UPDATE log SET qsl_rcvd = 'Y', qsl_rcvd_via = 'B', qslrdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
}
query.finish();
sqlOK = query.exec(queryString);
//queryString = QString("UPDATE log SET qsl_rcvd = 'Y', qsl_rcvd_via = 'B', qslrdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
if (sqlOK)
{
//qDebug() << "DataProxy_SQLite::qslRecViaBureau TRUE" << QT_ENDL;
query.finish();
//setDXCCAwardStatus(_qsoId);
//setWAZAwardStatus(_qsoId);
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
//qDebug() << "DataProxy_SQLite::qslRecViaBureau FALSE" << QT_ENDL;
query.finish();
return false;
}
bool DataProxy_SQLite::qslRecViaDirect(const int _qsoId, const QDate &_updateDate)
{
//qDebug() << "DataProxy_SQLite::qslRecViaDirect" << QT_ENDL;
QSqlQuery query;
QString queryString;
queryString = QString("UPDATE log SET qsl_rcvd = 'Y', qsl_rcvd_via = 'D', qslrdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.finish();
//setDXCCAwardStatus(_qsoId);
//setWAZAwardStatus(_qsoId);
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
query.finish();
return false;
}
bool DataProxy_SQLite::qslRecViaDirect(const int _qsoId, const QDate &_updateDate, const bool _queueSentQSL)
{
//qDebug() << "DataProxy_SQLite::qslRecViaDirect: " << _updateDate << QT_ENDL;
QSqlQuery query;
QString queryString;
bool sqlOK;
if (_queueSentQSL)
{
queryString = QString("SELECT qsl_sent FROM log WHERE id = '%1'").arg(_qsoId);
sqlOK = query.exec(queryString);
if(sqlOK)
{
query.next();
if (query.isValid())
{
queryString = (query.value(0)).toString();
if ((queryString == "Y") || (queryString == "R"))
{
// NO ACTION REQUIRED, QSL IS ALREADY SENT
//qDebug() << "DataProxy_SQLite::qslRecViaDirect: QSL already requested" << QT_ENDL;
queryString = QString("UPDATE log SET qsl_rcvd = 'Y', qsl_rcvd_via = 'D', qslrdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
}
else
{
//qDebug() << "DataProxy_SQLite::qslRecViaDirect: Request QSL-1" << QT_ENDL;
queryString = QString("UPDATE log SET qsl_rcvd = 'Y', qsl_rcvd_via = 'D', qsl_sent='R', qslrdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
}
}
else
{
//qDebug() << "DataProxy_SQLite::qslRecViaDirect: Request QSL-2" << QT_ENDL;
queryString = QString("UPDATE log SET qsl_rcvd = 'Y', qsl_rcvd_via = 'D', qsl_sent='R', qslrdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::qslRecViaDirect: Request QSL-3" << QT_ENDL;
queryString = QString("UPDATE log SET qsl_rcvd = 'Y', qsl_rcvd_via = 'D', qsl_sent='R', qslrdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
}
}
else
{
queryString = QString("UPDATE log SET qsl_rcvd = 'Y', qsl_rcvd_via = 'D', qslrdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
}
query.finish();
sqlOK = query.exec(queryString);
if (sqlOK)
{
//qDebug() << "DataProxy_SQLite::qslRecViaDirect TRUE" << QT_ENDL;
query.finish();
//setDXCCAwardStatus(_qsoId);
//setWAZAwardStatus(_qsoId);
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
//qDebug() << "DataProxy_SQLite::qslRecViaDirect FALSE" << QT_ENDL;
query.finish();
return false;
}
bool DataProxy_SQLite::qslSentAsRequested(const int _qsoId, const QDate &_updateDate)
{
//TODO: Add some protection to the data before modifying
//qDebug() << "DataProxy_SQLite::qslSentAsRequested" << QT_ENDL;
QSqlQuery query;
QString queryString;
queryString = QString("UPDATE log SET qsl_sent = 'R', qslsdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
//qDebug() << "DataProxy_SQLite::qslSentAsRequested: " << queryString << QT_ENDL;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
//qDebug() << "DataProxy_SQLite::qslSentAsRequested" << QT_ENDL;
query.finish();
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
query.finish();
return false;
}
bool DataProxy_SQLite::qslRecAsRequested(const int _qsoId, const QDate &_updateDate)
{
//TODO: Add some protection to the data before modifying
//qDebug() << "DataProxy_SQLite::qslRecAsRequested" << QT_ENDL;
QSqlQuery query;
QString queryString;
queryString = QString("UPDATE log SET qsl_rcvd = 'R', qslsdate = '%1' WHERE id = '%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
//qDebug() << "DataProxy_SQLite::qslRecAsRequested: " << queryString << QT_ENDL;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
//qDebug() << "DataProxy_SQLite::qslRecAsRequested OK" << QT_ENDL;
query.finish();
return true;
}
else
{
//qDebug() << "DataProxy_SQLite::qslRecAsRequested NOK" << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
query.finish();
return false;
}
bool DataProxy_SQLite::setClubLogSent(const int _qsoId, const QString &_st, const QDate &_updateDate)
{ // Updates the QSO with the ClubLog status & date
QSqlQuery query;
QString queryString;
queryString = QString("UPDATE log SET clublog_qso_upload_status = '%1', clublog_qso_upload_date = '%2' WHERE id = '%3'").arg(_st).arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
//qDebug() << "DataProxy_SQLite::setClubLogSent: " << queryString << QT_ENDL;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
//qDebug() << "DataProxy_SQLite::setClubLogSent - TRUE" << QT_ENDL;
query.finish();
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
//qDebug() << "DataProxy_SQLite::setClubLogSent - FALSE" << QT_ENDL;
query.finish();
return false;
}
bool DataProxy_SQLite::setLoTWQSLRec (const int _qsoId, const QString &_st, const QDate &_updateDate)
{
QSqlQuery query;
QString queryString;
if (!util->isValidQSL_Rcvd(_st))
{
return false;
}
if (!_updateDate.isValid())
{
return false;
}
queryString = QString("UPDATE log SET lotw_qsl_rcvd = '%1', lotw_qslrdate = '%2' WHERE id = '%3'").arg(_st).arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_qsoId);
//qDebug() << "DataProxy_SQLite::setLoTWQSLRec: " << queryString << QT_ENDL;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
//qDebug() << "DataProxy_SQLite::setLoTWQSLRec - TRUE" << QT_ENDL;
query.finish();
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
//qDebug() << "DataProxy_SQLite::setLoTWQSLRec - FALSE" << QT_ENDL;
query.finish();
return false;
}
bool DataProxy_SQLite::isQSOConfirmed(const int _qsoId, const bool _checkPaper, const bool _checkLoTW)
{ // Returns true if the QSO has been confirmed via paper and/or LoTW
QSqlQuery query;
QString queryString;
queryString = QString("SELECT qsl_rcvd, lotw_qsl_rcvd FROM log WHERE id = '%1'").arg(_qsoId);
if (!query.exec(queryString))
{
return false;
}
if (!query.next ())
{
return false;
}
if (!query.isValid ())
{
return false;
}
QString paperQSL = (query.value(0)).toString();
QString lotwQSL = (query.value(1)).toString();
query.finish();
if (_checkPaper && _checkLoTW)
{
return ((paperQSL == "Y") || (lotwQSL == "Y"));
}
else if (_checkPaper && !_checkLoTW)
{
return (paperQSL == "Y");
}
else if (!_checkPaper && _checkLoTW)
{
return (lotwQSL == "Y");
}
else
{
return false;
}
}
bool DataProxy_SQLite::isQSLReceived(const int _qsoId)
{
//qDebug() << "DataProxy_SQLite::isQSLReceived" << QString::number(_qsoId) << QT_ENDL;
QSqlQuery query;
QString queryString;
queryString = QString("SELECT qsl_rcvd FROM log WHERE id = '%1'").arg(_qsoId);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
queryString = (query.value(0)).toString();
query.finish();
if (queryString == "Y")
{
//qDebug() << "DataProxy_SQLitew::isQSLReceived: " << QString::number(_qsoId) << "QSL Received" << QT_ENDL;
return true;
}
else
{
//qDebug() << "DataProxy_SQLite::isQSLReceived: " << QString::number(_qsoId) << "QSL NOT Received-1" << QT_ENDL;
return false;
}
}
else
{
//qDebug() << "DataProxy_SQLite::isQSLReceived: " << QString::number(_qsoId) << "QSL NOT Received-2" << QT_ENDL;
query.finish();
return false;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
}
return false;
}
bool DataProxy_SQLite::isQSLSent(const int _qsoId)
{
//qDebug() << "DataProxy_SQLite::isQSLSent: " << QString::number(_qsoId) << QT_ENDL;
QSqlQuery query;
QString queryString;
queryString = QString("SELECT qsl_sent FROM log WHERE id = '%1'").arg(_qsoId);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
queryString = (query.value(0)).toString();
query.finish();
if (queryString == "Y")
{
//qDebug() << "DataProxy_SQLite::isQSLSent: " << QString::number(_qsoId) << "QSL Sent" << QT_ENDL;
return true;
}
else
{
//qDebug() << "DataProxy_SQLite::isQSLSent: " << QString::number(_qsoId) << "QSL NOT Sent-1" << QT_ENDL;
return false;
}
}
else
{
//qDebug() << "DataProxy_SQLite::isQSLSent: " << QString::number(_qsoId) << "QSL NOT Sent-2" << QT_ENDL;
return false;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
//return false;
}
int DataProxy_SQLite::getBandFromId(const int _qsoId)
{
QSqlQuery query;
QString queryString = QString("SELECT bandid FROM log WHERE id='%1'").arg(_qsoId);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
}
return -1;
}
int DataProxy_SQLite::getModeFromId(const int _qsoId)
{
QSqlQuery query;
QString queryString = QString("SELECT modeid FROM log WHERE id='%1'").arg(_qsoId);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
}
return -1;
}
int DataProxy_SQLite::getDXCCFromId(const int _qsoId)
{
QSqlQuery query;
QString queryString = QString("SELECT dxcc FROM log WHERE id='%1'").arg(_qsoId);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
}
return -1;
}
int DataProxy_SQLite::getCQZFromId(const int _qsoId)
{
QSqlQuery query;
QString queryString = QString("SELECT cqz FROM log WHERE id='%1'").arg(_qsoId);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
}
return -1;
}
QList DataProxy_SQLite::getBandModeDXCCCQZlogIDFromId(const int _qsoId)
{
QList result;
result.clear();
QSqlQuery query;
QString queryString = QString("SELECT bandid, modeid, dxcc, cqz, lognumber FROM log WHERE id='%1'").arg(_qsoId);
if (!query.exec(queryString))
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish ();
return result;
}
if (!query.next ())
{
query.finish ();
return result;
}
if (!query.isValid ())
{
query.finish ();
return result;
}
QSqlRecord rec = query.record();
int nameCol = rec.indexOf("bandid");
int v = (query.value(nameCol)).toInt();
if (v<1)
{
return result;
}
result.append (v);
nameCol = rec.indexOf("modeid");
v = (query.value(nameCol)).toInt();
v = (query.value(nameCol)).toInt();
if (v<1)
{
result.clear();
return result;
}
result.append (v);
nameCol = rec.indexOf("dxcc");
v = (query.value(nameCol)).toInt();
v = (query.value(nameCol)).toInt();
if (v<1)
{
result.clear();
return result;
}
result.append (v);
nameCol = rec.indexOf("cqz");
v = (query.value(nameCol)).toInt();
v = (query.value(nameCol)).toInt();
if (v<1)
{
result.clear();
return result;
}
result.append (v);
nameCol = rec.indexOf("lognumber");
v = (query.value(nameCol)).toInt();
v = (query.value(nameCol)).toInt();
if (v<1)
{
result.clear();
return result;
}
result.append (v);
query.finish ();
return result;
}
QString DataProxy_SQLite::getCallFromId(const int _qsoId)
{
//qDebug() << "DataProxy_SQLite::getCallFromId" << QT_ENDL;
QSqlQuery query;
QString queryString = QString("SELECT call FROM log WHERE id='%1'").arg(_qsoId);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
QString v = (query.value(0)).toString();
query.finish();
return v;
}
else
{
query.finish();
return QString();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
}
return QString();
}
QStringList DataProxy_SQLite::getClubLogRealTimeFromId(const int _qsoId)
{
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: " << QString::number(_qsoId) << QT_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,
LOTW_QSL_RCVD, QSL_SENT, DXCC, PROP_MODE, CREDIT_GRANTED
*/
QSqlQuery query;
int nameCol = -1;
QStringList dataC = QStringList();
//QString aux1 = QString();
//QString aux2 = QString();
//QString call = QString();
// IMPORTANT: band_rx is not always present, and if it is not present, the query with INNER JOIN will fail.
// To fix that we will do two queries, one to check if I have all the data and if not another one with a reduced scope.
QString queryString = QString("SELECT band_rx FROM log WHERE id='%1'").arg(_qsoId);
bool sqlOk = query.exec(queryString);
bool haveBandRX = false;
if (sqlOk)
{
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: sqlOK -1" << QT_ENDL;
if (query.next())
{
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: qsl next -1" << QT_ENDL;
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: sql valid -1" << QT_ENDL;
QSqlRecord rec = query.record();
nameCol = rec.indexOf("band_rx");
QString aux = (query.value(nameCol)).toString();
if (aux.length()<1)
{ // We DON'T have a band_rx available
query.finish();
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: without BAND-RX" << QT_ENDL;
queryString = QString("SELECT qso_date, qslrdate, qslsdate, call, station_callsign, operator, M.name, B.name, freq, qsl_rcvd, lotw_qsl_rcvd, qsl_sent, dxcc, prop_mode, credit_granted FROM log INNER JOIN band as B ON bandid = B.id INNER JOIN mode as M ON modeid = M.id WHERE log.id='%1'").arg(_qsoId);
}
else {
haveBandRX = true;
queryString = QString("SELECT qso_date, qslrdate, qslsdate, call, station_callsign, operator, M.name, B.name, R.name, freq, qsl_rcvd, lotw_qsl_rcvd, qsl_sent, dxcc, prop_mode, credit_granted FROM log INNER JOIN band as B ON bandid = B.id INNER JOIN band as R ON band_rx = R.id INNER JOIN mode as M ON modeid = M.id WHERE log.id='%1'").arg(_qsoId);
}
}
else
{ // We have a band_rx available
query.finish();
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: NO VALID" << QT_ENDL;
return QStringList();
}
}
else
{
query.finish();
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: ERROR-1" << QT_ENDL;
return QStringList();
}
}
else
{
query.finish();
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: ERROR-2" << QT_ENDL;
return QStringList();
}
sqlOk = query.exec(queryString);
dataC << QString::number(_qsoId);
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: lastQuery: " << query.lastQuery() << QT_ENDL;
if (sqlOk)
{
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId sqlOK-1" << QT_ENDL;
if (query.next())
{
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId query next = OK" << QT_ENDL;
if (query.isValid())
{
QSqlRecord rec = query.record();
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId query valid = OK" << QT_ENDL;
QString aux;
nameCol = rec.indexOf("qso_date");
aux = util->getADIFDateFromQDateTime(util->getDateTimeFromSQLiteString((query.value(nameCol)).toString()));
if (aux.length()<1)
{
query.finish();
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: ERROR-3: " << aux << QT_ENDL;
return QStringList();
}
dataC << aux;
aux = util->getADIFTimeFromQDateTime(util->getDateTimeFromSQLiteString((query.value(nameCol)).toString()));
if (aux.length()<1)
{
query.finish();
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: ERROR-4: " << aux<< endl;
return QStringList();
}
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId Time_on: " << aux << QT_ENDL;
dataC << aux;
//dataC << (query.value(nameCol)).toString();
nameCol = rec.indexOf("qslrdate");
dataC << util->getADIFDateFromQDate( util->getDateFromSQliteString((query.value(nameCol)).toString()) );
//dataC << (query.value(nameCol)).toString();
nameCol = rec.indexOf("qslsdate");
dataC << util->getADIFDateFromQDate( util->getDateFromSQliteString((query.value(nameCol)).toString()) );
//dataC << (query.value(nameCol)).toString();
nameCol = rec.indexOf("call");
if (aux.length()<1)
{
query.finish();
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: ERROR-5: " << aux << QT_ENDL;
return QStringList();
}
QString call = (query.value(nameCol)).toString();
dataC << call;
nameCol = rec.indexOf("operator");
dataC << (query.value(nameCol)).toString();
//nameCol = rec.indexOf("M.name"); //MODE //TODO: Fix this to get the proper column
aux = (query.value(6)).toString();
if (aux.length()<1)
{
query.finish();
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: ERROR-6: " << aux<< endl;
return QStringList();
}
dataC << aux;
//nameCol = rec.indexOf("B.name"); // BAND
aux = (query.value(7)).toString();
if (aux.length()<1)
{
query.finish();
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: ERROR-7: " << aux << QT_ENDL;
return QStringList();
}
dataC << aux;
if (haveBandRX)
{
dataC << (query.value(8)).toString();
}
else
{
dataC << "";
}
//nameCol = rec.indexOf("R.name"); //BAND_RX //TODO: Fix this to get the proper column (use an index instead of a number)
nameCol = rec.indexOf("freq");
dataC << (query.value(nameCol)).toString();
nameCol = rec.indexOf("qsl_rcvd");
dataC << (query.value(nameCol)).toString();
nameCol = rec.indexOf("lotw_qsl_rcvd");
dataC << (query.value(nameCol)).toString();
nameCol = rec.indexOf("qsl_sent");
dataC << (query.value(nameCol)).toString();
nameCol = rec.indexOf("dxcc");
dataC << (query.value(nameCol)).toString();
nameCol = rec.indexOf("prop_mode");
dataC << (query.value(nameCol)).toString();
nameCol = rec.indexOf("credit_granted");
dataC << (query.value(nameCol)).toString();
nameCol = rec.indexOf("station_callsign");
QString aux2 = (query.value(nameCol)).toString();
if (util->isValidCall(aux2))
{
dataC << aux2;
}
else
{
dataC << call;
}
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: RETURNING ... OK" << QT_ENDL;
query.finish();
return dataC;
}
else
{
//NO VALID
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId NO VALID NOT OK" << QT_ENDL;
query.finish();
return QStringList();
}
}
}
else
{
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId NOT sqlOK" << QT_ENDL;
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: 2 LastQuery: " << query.lastQuery() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: 2 LastError-data: " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: 2 LastError-driver: " << query.lastError().driverText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: 2 LastError-n: " << QString::number(query.lastError().nativeErrorCode() ) << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QStringList();
}
//qDebug() << "DataProxy_SQLite::getClubLogRealTimeFromId: ERROR-10" << QT_ENDL;
return QStringList();
}
QString DataProxy_SQLite::getNameFromQRZ(const QString &_call)
{
if (_call.length() <= 0)
{
//qDebug() << "DataProxy_SQLite::getNameFromQRZ return 0" << QT_ENDL;
return QString();
}
QSqlQuery query;
QString queryString = QString("SELECT name FROM log WHERE call='%0'").arg(_call);
bool sqlOk = query.exec(queryString);
if (sqlOk)
{
while (query.next())
{
if (query.isValid())
{
if (((query.value(0)).toString()).length()>0)
{
//qDebug() << "DataProxy_SQLite::getNameFromQRZ: " << (query.value(0)).toString() << QT_ENDL;
QString v = (query.value(0)).toString();
query.finish();
return v;
}
}
}
query.finish();
//qDebug() << "DataProxy_SQLite::getNameFromQRZ: NO NAME" << QT_ENDL;
return QString();
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
}
QString DataProxy_SQLite::getQTHFromQRZ(const QString &_call)
{
if (_call.length() <= 0)
{
return QString();
}
QSqlQuery query;
QString queryString = QString("SELECT qth FROM log WHERE call='%0'").arg(_call);
bool sqlOk = query.exec(queryString);
if (sqlOk)
{
while (query.next())
{
if (query.isValid())
{
if (((query.value(0)).toString()).length()>0)
{
QString v = (query.value(0)).toString();
query.finish();
return v;
}
}
}
query.finish();
return QString();
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
}
QString DataProxy_SQLite::getLocatorFromQRZ(const QString &_call)
{
if (_call.length() <= 0)
{
return QString();
}
QSqlQuery query;
QString queryString = QString("SELECT gridsquare FROM log WHERE call='%0'").arg(_call);
bool sqlOk = query.exec(queryString);
if (sqlOk)
{
while (query.next())
{
if (query.isValid())
{
if (((query.value(0)).toString()).length()>0)
{
QString v = (query.value(0)).toString();
query.finish();
return v;
}
}
}
query.finish();
return QString();
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
}
QString DataProxy_SQLite::getIOTAFromQRZ(const QString &_call)
{
if (_call.length() <= 0)
{
return QString();
}
QSqlQuery query;
QString queryString = QString("SELECT iota FROM log WHERE call='%0'").arg(_call);
bool sqlOk = query.exec(queryString);
if (sqlOk)
{
while (query.next())
{
if (query.isValid())
{
if (((query.value(0)).toString()).length()>0)
{
QString v = (query.value(0)).toString();
query.finish();
return v;
}
}
}
query.finish();
return QString();
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
}
QString DataProxy_SQLite::getQSLViaFromQRZ(const QString &_call)
{
if (_call.length() <= 0)
{
return QString();
}
QSqlQuery query;
QString queryString = QString("SELECT DISTINCT qsl_via FROM log WHERE call='%0'").arg(_call);
bool sqlOk = query.exec(queryString);
if (sqlOk)
{
while (query.next())
{
if (query.isValid())
{
if (((query.value(0)).toString()).length()>0)
{
QString v = (query.value(0)).toString();
query.finish();
return v;
}
}
}
query.finish();
return QString();;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
}
bool DataProxy_SQLite::updateAwardDXCC()
{
//qDebug() << "DataProxy_SQLite::updateAwardDXCC" << QT_ENDL;
fillEmptyDXCCInTheLog();
return db->updateAwardDXCCTable();
//qDebug() << "DataProxy_SQLite::updateAwardDXCC-END" << QT_ENDL;
}
bool DataProxy_SQLite::updateAwardWAZ()
{
//qDebug() << "DataProxy_SQLite::updateAwardWAZ" << QT_ENDL;
return db->updateAwardWAZTable();
}
bool DataProxy_SQLite::QRZCOMModifyFullLog(const int _currentLog)
{
//qDebug() << " DataProxy_SQLite::QRZCOMModifyFullLog" << QString::number(_currentLog) << QT_ENDL;
if (!doesThisLogExist(_currentLog))
{
return false;
}
QString queryString;
bool sqlOK;
QSqlQuery query;
queryString = QString("UPDATE log SET qrzcom_qso_upload_status = 'M', qrzcom_qso_upload_date = '%1'").arg(util->getDateSQLiteStringFromDate(QDate::currentDate()));
sqlOK = query.exec(queryString);
query.finish();
if (sqlOK)
{
//qDebug() << " DataProxy_SQLite::QRZCOMModifyFullLog: END TRUE" << QT_ENDL;
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << " DataProxy_SQLite::QRZCOMModifyFullLog: END FALSE: " << query.lastError().databaseText() << QT_ENDL;
return false;
}
//qDebug() << " DataProxy_SQLite::QRZCOMModifyFullLog: END TRUE" << QT_ENDL;
//return false;
}
bool DataProxy_SQLite::QRZCOMSentQSOs(const QList &_qsos)
{
//qDebug() << " DataProxy_SQLite::QRZCOMSentQSOs" << QString::number(_qsos.count()) << QT_ENDL;
if (_qsos.count() < 1)
{
return true;
}
QString queryString;
bool sqlOK;
QSqlQuery query;
for (int i = 0; i< _qsos.count(); i++)
{
//qDebug() << " DataProxy_SQLite::QRZCOMLSentQSOs: updating QSO: " << QString::number(_qsos.at(i)) << QT_ENDL;
queryString = QString("UPDATE log SET qrzcom_qso_upload_status = 'Y', qrzcom_qso_upload_date = '%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::QRZCOMSentQSOs: exec: " << query.lastQuery() << QT_ENDL;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << " DataProxy_SQLite::QRZCOMSentQSOs: END FALSE" << QT_ENDL;
return false;
}
}
//qDebug() << " DataProxy_SQLite::QRZCOMSentQSOs: END TRUE" << QT_ENDL;
return true;
}
bool DataProxy_SQLite::clublogSentQSOs(const QList &_qsos)
{
//qDebug() << " DataProxy_SQLite::clublogSentQSOs" << QString::number(_qsos.count()) << QT_ENDL;
if (_qsos.count() < 1)
{
return true;
}
QString queryString;
bool sqlOK;
QSqlQuery query;
for (int i = 0; i< _qsos.count(); i++)
{
//qDebug() << " DataProxy_SQLite::lotwSentQSOs: updating QSO: " << QString::number(_qsos.at(i)) << QT_ENDL;
queryString = QString("UPDATE log SET clublog_qso_upload_status = 'Y', clublog_qso_upload_date = '%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::clublogSentQSOs: exec: " << query.lastQuery() << QT_ENDL;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << " DataProxy_SQLite::clublogSentQSOs: END FALSE" << QT_ENDL;
return false;
}
}
//qDebug() << " DataProxy_SQLite::clublogSentQSOs: END TRUE" << QT_ENDL;
return true;
}
bool DataProxy_SQLite::clublogModifyFullLog(const int _currentLog)
{
//qDebug() << " DataProxy_SQLite::clublogModifyFullLog" << QString::number(_currentLog) << QT_ENDL;
if (!doesThisLogExist(_currentLog))
{
return false;
}
QString queryString;
bool sqlOK;
QSqlQuery query;
queryString = QString("UPDATE log SET clublog_qso_upload_status = 'M', clublog_qso_upload_date = '%1'").arg(util->getDateSQLiteStringFromDate(QDate::currentDate()));
sqlOK = query.exec(queryString);
query.finish();
if (sqlOK)
{
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << " DataProxy_SQLite::clublogModifyFullLog: END FALSE" << QT_ENDL;
return false;
}
//qDebug() << " DataProxy_SQLite::clublogModifyFullLog: END TRUE" << QT_ENDL;
//return false;
}
bool DataProxy_SQLite::eQSLModifyFullLog(const int _currentLog)
{
//qDebug() << " DataProxy_SQLite::eQSLModifyFullLog" << QString::number(_currentLog) << QT_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" << QT_ENDL;
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << " DataProxy_SQLite::eQSLModifyFullLog: END FALSE: " << query.lastError().databaseText() << QT_ENDL;
return false;
}
//qDebug() << " DataProxy_SQLite::eQSLModifyFullLog: END TRUE" << QT_ENDL;
}
bool DataProxy_SQLite::eQSLSentQSOs(const QList &_qsos)
{
//qDebug() << " DataProxy_SQLite::eQSLSentQSOs" << QString::number(_qsos.count()) << QT_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)) << QT_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() << QT_ENDL;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << " DataProxy_SQLite::eQSLSentQSOs: END FALSE" << QT_ENDL;
return false;
}
}
//qDebug() << " DataProxy_SQLite::eQSLSentQSOs: END TRUE" << QT_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,
const QString &_stationcallsign, const QString &_name, const QString &_operator,
const QDateTime &_datetime, const QDateTime &_datetime_off, const double txpower,
const int _dxcc, const int _logNumber, bool _sendQSL)
{
//qDebug() << "DataProxy_SQLite::addQSOFromWSJTX: " << _dxcall << QT_ENDL;
//void MainWindow::slotWSJTXloggedQSO(const int _type, const QString &_dxcall, const quint64 _freq, const QString &_mode,
// const QString &_dx_grid, const QString &_time_off, const QString &_report_sent, const QString &_report_rec,
// const QString &_tx_power, const QString &_comments, const QString &_name, const QString &_time_on)
//_qso format: Date/TimeOn/call/bandid/modeid/freq/dxgrid/timeOff/rsttx/rstrx/txpower/comments/name
/*
Mandatory data:
"qso_date VARCHAR(10) NOT NULL, "
"call VARCHAR(40) NOT NULL, "
"bandid INTEGER NOT NULL, "
"modeid INTEGER NOT NULL, "
*/
QString stringFields = QString();
QString stringData = QString();
QString stringQuery = QString();
QSqlQuery query;
if (util->isValidCall(_dxcall))
{
stringFields = "call, ";
stringData = "'" + _dxcall + "', ";
}
else
{
//qDebug() << "DataProxy_SQLite::addQSOFromWSJTX: Error: call" << QT_ENDL;
return false;
}
if (_datetime.isValid())
{
//qDebug() << "DataProxy_SQLite::addQSOFromWSJTX: time-on: " << _datetime << QT_ENDL;
stringFields = stringFields + "qso_date, ";
QDateTime _dateTime;
//_dateTime.setDate(QDate::currentDate());
//_dateTime.setTime(QTime::fromString(_time_on, "yyyyMMddhhmmss"));
//qDebug() << "DataProxy_SQLite::addQSOFromWSJTX: time-on: " << _datetime << QT_ENDL;
//stringData = stringData + "'" + QDateTime::fromString(_time_on, "yyyyMMddhhmmss").toString("yyyy-MM-dd") + "', '" + QDateTime::fromString(_time_on, "yyyyMMddhhmmss").toString("hh:mm:ss") + "', ";
stringData = stringData + "'" + util->getDateTimeSQLiteStringFromDateTime(_datetime) + "', ";
//qDebug() << "DataProxy_SQLite::addQSOFromWSJTX: time-on: " << stringData << QT_ENDL;
}
else
{
//qDebug() << "DataProxy_SQLite::addQSOFromWSJTX: Error: time-on_ " << _datetime << QT_ENDL;
return false;
}
QString band = getBandNameFromFreq(_freq);
if (band != _band)
{
//qDebug() << "DataProxy_SQLite::addQSOFromWSJTX: Error: FREQ / BAND inconsistency " << _band << "/" << QString::number(_freq) << QT_ENDL;
}
if (band.length()>0)
{
stringFields = stringFields + "bandid, " ;
stringData = stringData + "'" + QString::number(getBandIdFromFreq(_freq)) + "', ";
stringFields = stringFields + "freq, " ;
stringData = stringData + "'" + QString::number(_freq) + "', ";
// EA5WA fix to add the freq RX into the log
stringFields = stringFields + "freq_rx, " ;
stringData = stringData + "'" + QString::number(_freq) + "', ";
}
else
{
//qDebug() << "DataProxy_SQLite::addQSOFromWSJTX: Error: band" << QT_ENDL;
emit queryError(Q_FUNC_INFO, "Incorrect band: " + _band, "-1000", "No query error");
return false;
}
int _modeid = getSubModeIdFromSubMode(_mode);
//qDebug() << "DataProxy_SQLite::addQSOFromWSJTX: mode: " << _mode << QT_ENDL;
//qDebug() << "DataProxy_SQLite::addQSOFromWSJTX: modeid: " << QString::number(_modeid) << QT_ENDL;
if (util->isValidModeId(_modeid))
{
stringFields = stringFields + "modeid, ";
stringData = stringData + "'" + QString::number(_modeid) + "', ";
}
else
{
//qDebug() << "DataProxy_SQLite::addQSOFromWSJTX: Error: mode" << QT_ENDL;
emit queryError(Q_FUNC_INFO, "Incorrect mode: " + _mode, "-1000", "No query error");
return false;
}
if (_datetime_off.isValid())
{
stringFields = stringFields + "qso_date_off, ";
stringData = stringData + "'" + util->getDateTimeSQLiteStringFromDateTime(_datetime_off) + "', ";
}
if (util->isValidRST(_rstTX))
{
stringFields = stringFields + "rst_sent, ";
stringData = stringData + "'" + _rstTX + "', ";
}
if (util->isValidRST(_rstRX))
{
stringFields = stringFields + "rst_rcvd, ";
stringData = stringData + "'" + _rstRX + "', ";
}
if (_sTX.length()>0)
{
stringFields = stringFields + "stx_string, ";
stringData = stringData + "'" + _sTX + "', ";
}
if (_sRX.length()>0)
{
stringFields = stringFields + "srx_string, ";
stringData = stringData + "'" + _sRX + "', ";
}
if (_comment.length()>0)
{
stringFields = stringFields + "comment, ";
stringData = stringData + "'" + _comment + "', ";
}
if (_name.length()>0)
{
stringFields = stringFields + "name, ";
stringData = stringData + "'" + _name + "', ";
}
if (util->isValidGrid(_dxgrid))
{
stringFields = stringFields + "gridsquare, ";
stringData = stringData + "'" + _dxgrid + "', ";
}
if (util->isValidGrid(_mygrid))
{
stringFields = stringFields + "my_gridsquare, ";
stringData = stringData + "'" + _mygrid + "', ";
}
if (util->isValidPower(QString::number(txpower)))
{
stringFields = stringFields + "tx_pwr, ";
stringData = stringData + "'" + QString::number(txpower) + "', ";
}
if (util->isValidCall(_operator))
{
stringFields = stringFields + "operator, ";
stringData = stringData + "'" + _operator + "', ";
}
if (util->isValidCall(_stationcallsign))
{
stringFields = stringFields + "station_callsign, ";
stringData = stringData + "'" + _stationcallsign + "', ";
}
if (_dxcc>0)
{
stringFields = stringFields + "dxcc, ";
stringData = stringData + "'" + QString::number(_dxcc) + "', ";
int _cqz, _ituz;
_cqz = getCQzFromEntity(_dxcc);
_ituz = getITUzFromEntity(_dxcc);
if (_cqz >0)
{
stringFields = stringFields + "cqz, ";
stringData = stringData + "'" + QString::number(_cqz) + "', ";
}
if (_ituz >0)
{
stringFields = stringFields + "ituz, ";
stringData = stringData + "'" + QString::number(_ituz) + "', ";
}
}
if (_sendQSL)
{
stringFields = stringFields + "qsl_via, ";
stringData = stringData + "'B', ";
stringFields = stringFields + "lotw_qsl_sent, ";
stringData = stringData + "'Q', ";
stringFields = stringFields + "eqsl_qsl_sent, ";
stringData = stringData + "'Q', ";
stringFields = stringFields + "hrdlog_qso_upload_status, ";
stringData = stringData + "'M', ";
stringFields = stringFields + "clublog_qso_upload_status, ";
stringData = stringData + "'M', ";
stringFields = stringFields + "qrzcom_qso_upload_status, ";
stringData = stringData + "'M', ";
}
stringFields = stringFields + "lognumber";
stringData = stringData + "'" + QString::number(_logNumber) + "'";
stringQuery = "INSERT INTO log (" + stringFields + ") values (" + stringData +")" ;
//qDebug() << "DataProxy_SQLite::addQSOFromWSJTX: Query: " << stringQuery << QT_ENDL;
bool sqlOK = query.exec(stringQuery);
//qDebug() << "DataProxy_SQLite::addQSOFromWSJTX: LastQuery: " << query.lastQuery() << QT_ENDL;
if (sqlOK)
{
query.finish();
//qDebug() << "DataProxy_SQLite::addQSOFromWSJTX: SQL OK" << QT_ENDL;
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
//qDebug() << "DataProxy_SQLite::addQSOFromWSJTX: Error: SQL " << QT_ENDL;
return false;
}
}
int DataProxy_SQLite::addQSOFromLoTW(const QString &_call, const QDateTime _datetime, const QString &_mode, const QString &_band, const double _freq, const QDate _qslrdate, const QString &_stationcallsign, const int _logn)
{
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: " << _call << QT_ENDL;
/*
Mandatory data:
"qso_date VARCHAR(10) NOT NULL, "
"call VARCHAR(40) NOT NULL, "
"bandid INTEGER NOT NULL, "
"modeid INTEGER NOT NULL, "
"lognumber"
*/
QString stringFields = QString();
QString stringData = QString();
QString stringQuery = QString();
//getITUzFromEntity()
QSqlQuery query;
if (util->isValidCall(_call))
{
stringFields = "call, ";
stringData = "'" + _call + "', ";
}
else
{
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: Error: call" << QT_ENDL;
return -1;
}
if (_datetime.isValid())
{
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: time-on: " << _datetime << QT_ENDL;
stringFields = stringFields + "qso_date, ";
QDateTime _dateTime;
stringData = stringData + "'" + util->getDateTimeSQLiteStringFromDateTime(_datetime) + "', ";
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: time-on: " << stringData << QT_ENDL;
}
else
{
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: Error: time-on_ " << _datetime << QT_ENDL;
return -2;
}
QString band = getBandNameFromFreq(_freq);
if (band != _band)
{
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: Error: FREQ / BAND inconsistency " << _band << "/" << QString::number(_freq) << QT_ENDL;
}
if (band.length()>0)
{
stringFields = stringFields + "bandid, " ;
stringData = stringData + "'" + QString::number(getBandIdFromFreq(_freq)) + "', ";
stringFields = stringFields + "freq, " ;
stringData = stringData + "'" + QString::number(_freq) + "', ";
}
else
{
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: Error: band" << QT_ENDL;
emit queryError(Q_FUNC_INFO, "Incorrect band: " + _band, "-1000", "No query error");
return -3;
}
int _modeid = getSubModeIdFromSubMode(_mode);
if (util->isValidModeId(_modeid))
{
stringFields = stringFields + "modeid, ";
stringData = stringData + "'" + QString::number(_modeid) + "', ";
QString rst = util->getDefaultRST(_mode);
if (rst.length()>0)
{
stringFields = stringFields + "rst_sent, ";
stringData = stringData + "'" + rst + "', ";
stringFields = stringFields + "rst_rcvd, ";
stringData = stringData + "'" + rst + "', ";
}
}
else
{
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: Error: mode" << QT_ENDL;
emit queryError(Q_FUNC_INFO, "Incorrect mode: " + _mode, "-1000", "No query error");
return -4;
}
if (_qslrdate.isValid())
{
stringFields = stringFields + "lotw_qslrdate, ";
stringData = stringData + "'" + util->getDateSQLiteStringFromDate(_qslrdate) + "', ";
stringFields = stringFields + "lotw_qsl_rcvd, ";
stringData = stringData + "'Y', ";
stringFields = stringFields + "lotw_qsl_sent, ";
stringData = stringData + "'Q', ";
}
if (util->isValidCall(_stationcallsign))
{
stringFields = stringFields + "station_callsign, ";
stringData = stringData + "'" + _stationcallsign + "', ";
}
int _dxcc = getDXCCFromPrefix(_call);
if (_dxcc>0)
{
stringFields = stringFields + "dxcc, ";
stringData = stringData + "'" + QString::number(_dxcc) + "', ";
int _cqz, _ituz;
_cqz = getCQzFromEntity(_dxcc);
_ituz = getITUzFromEntity(_dxcc);
if (_cqz >0)
{
stringFields = stringFields + "cqz, ";
stringData = stringData + "'" + QString::number(_cqz) + "', ";
}
if (_ituz >0)
{
stringFields = stringFields + "ituz, ";
stringData = stringData + "'" + QString::number(_ituz) + "', ";
}
}
stringFields = stringFields + "lognumber";
stringData = stringData + "'" + QString::number(_logn) + "'";
stringQuery = "INSERT INTO log (" + stringFields + ") values (" + stringData +")" ;
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: Query: " << stringQuery << QT_ENDL;
bool sqlOK = query.exec(stringQuery);
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: LastQuery: " << query.lastQuery() << QT_ENDL;
if (sqlOK)
{
//query.finish();
if (query.exec("SELECT MAX(id) FROM log"))
{
if (query.next())
{
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: NOT VALID" << QT_ENDL;
}
}
else
{
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: QUERY EXEC NOT NEXT" << QT_ENDL;
}
}
else
{
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: NOT OK: " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: NOT OK: " << QString::number(query.lastError().nativeErrorCode()) << QT_ENDL;
}
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: SQL OK" << QT_ENDL;
return -5;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
//qDebug() << "DataProxy_SQLite::addQSOFromLoTW: Error: SQL " << QT_ENDL;
return -100;
}
}
bool DataProxy_SQLite::deleteQSO(const int _qsoId)
{
//qDebug() << "DataProxy_SQLite::deleteQSO" << QT_ENDL;
QSqlQuery query;
QString queryString = QString("DELETE FROM log WHERE id='%1'").arg(_qsoId);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.finish();
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
}
int DataProxy_SQLite::isWorkedB4(const QString &_qrz, const int _currentLog)
{
//qDebug() << "DataProxy_SQLite::isWorkedB4" << QT_ENDL;
//Returns the QSO id
QSqlQuery query;
QString queryString;
if (_currentLog < 0)
{
queryString = QString("SELECT id FROM log WHERE call='%1'").arg(_qrz);
}
else
{
queryString = QString("SELECT id FROM log WHERE call='%1' AND lognumber='%2'").arg(_qrz).arg(_currentLog);
}
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
}
QList DataProxy_SQLite::isThisQSODuplicated(const QString &_callingFunc, const QString &_qrz, const QDateTime &_dateTime, const int _band, const int _mode, const int _secs)
//QList DataProxy_SQLite::isThisQSODuplicated(const QString &_qrz, const QDateTime &_dateTime, const int _band, const int _mode)
{
//qDebug() << "DataProxy_SQLite::isThisQSODuplicated" << QT_ENDL;
QSqlQuery query;
QString queryString;
QList dupeQsos;
dupeQsos.clear();
int validityPeriod = 15 * 60;
QString initTime = util->getDateTimeSQLiteStringFromDateTime(_dateTime.addSecs(-validityPeriod));
QString endTime = util->getDateTimeSQLiteStringFromDateTime(_dateTime.addSecs(validityPeriod));
//yyyy-MM-dd hh:mm:ss
// We will match +-15min
queryString = QString("SELECT id, qso_date FROM log WHERE call='%1' AND bandid='%2' AND modeid='%3' AND qso_date>'%4' AND qso_date<'%5'").arg(_qrz).arg(_band).arg(_mode).arg(initTime).arg(endTime);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
while (query.next())
{
if (query.isValid())
{
int dupeQSO = (query.value(0)).toInt();
if (dupeQSO>0)
{
dupeQsos.append(dupeQSO);
}
}
else
{
//qDebug() << "DataProxy_SQLite::isThisQSODuplicated - not valid" << QT_ENDL;
}
}
return dupeQsos;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return dupeQsos;
}
}
int DataProxy_SQLite::getDuplicatedQSOId(const QString &_qrz, const QDateTime &_datetime, const int _band, const int _mode)
{
//qDebug() << "DataProxy_SQLite::isThisQSODuplicated" << QT_ENDL;
QSqlQuery query;
QString queryString;
QString datetime = util->getDateTimeSQLiteStringFromDateTime(_datetime);
queryString = QString("SELECT id FROM log WHERE call='%1' AND qso_date='%2' AND bandid='%4' AND modeid='%5'").arg(_qrz).arg(datetime).arg(_band).arg(_mode);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int qsoId = (query.value(0)).toInt();
if (qsoId)
{
query.finish();
return qsoId;
}
else
{
query.finish();
return -1;
}
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
//return -1;
}
bool DataProxy_SQLite::isDXCCConfirmed(const int _dxcc, const int _currentLog)
{
//qDebug() << "DataProxy_SQLite::isDXCCConfirmed: " << QString::number(_dxcc) << "/" << QString::number(_currentLog) << QT_ENDL;
QString queryString = QString("SELECT confirmed from awarddxcc WHERE dxcc='%1' AND lognumber='%2'").arg(_dxcc).arg(_currentLog);
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
if ( (query.value(0)).toInt() == 1)
{
//qDebug() << "DataProxy_SQLite::isDXCCConfrmed: TRUE" << QT_ENDL;
query.finish();
return true;
}
else
{
//qDebug() << "DataProxy_SQLite::isDXCCConfrmed: FALSE1" << QT_ENDL;
query.finish();
return false;
}
}
else
{
//qDebug() << "DataProxy_SQLite::isDXCCConfrmed: FALSE2" << QT_ENDL;
query.finish();
return false;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::isDXCCConfrmed: FALSE3" << QT_ENDL;
query.finish();
return false;
}
}
bool DataProxy_SQLite::isHF(const int _band)
{// 160M is considered as HF
if ( (_band>=getIdFromBandName("10M")) && (_band<=getIdFromBandName("160M")) )
{
//qDebug() << "DataProxy_SQLite::isHF: TRUE" << QT_ENDL;
return true;
}
else
{
//qDebug() << "DataProxy_SQLite::isHF: FALSE" << QT_ENDL;
return false;
}
}
bool DataProxy_SQLite::isWARC(const int _band)
{
if ( (_band==getIdFromBandName("12M")) || (_band==getIdFromBandName("17M")) || ((_band==getIdFromBandName("30M")) ) )
{
//qDebug() << "DataProxy_SQLite::isWARC: tRUE" << QT_ENDL;
return true;
}
else
{
//qDebug() << "DataProxy_SQLite::isWARC: FALSE" << QT_ENDL;
return false;
}
}
bool DataProxy_SQLite::isVHF(const int _band)
{
if (_band<=getIdFromBandName("6M"))
{
//qDebug() << "DataProxy_SQLite::isVHF: TRUE" << QT_ENDL;
return true;
}
else
{
//qDebug() << "DataProxy_SQLite::isVHF: FALSE" << QT_ENDL;
return false;
}
}
bool DataProxy_SQLite::isUHF(const int _band)
{
if (_band<=getIdFromBandName("70CM"))
{
//qDebug() << "DataProxy_SQLite::isUHF: TRUE" << QT_ENDL;
return true;
}
else
{
//qDebug() << "DataProxy_SQLite::isUHF: FALSE" << QT_ENDL;
return false;
}
}
QStringList DataProxy_SQLite::getOperatingYears(const int _currentLog)
{
//qDebug() << "DataProxy_SQLite::getYearsOperating: " << QString::number(_currentLog) << QT_ENDL;
QStringList years = QStringList();
//QStringList yearsSorted = QStringList();
QSqlQuery query;
QString queryString;
if (_currentLog<0)
{
queryString = QString("SELECT DISTINCT (substr (qso_date, 0, 5)) FROM log ORDER BY 'qso_date'");
}
else
{
queryString = QString("SELECT DISTINCT (substr (qso_date, 0, 5)) FROM log WHERE lognumber='%0' ORDER BY 'qso_date'").arg(_currentLog);
}
QString year = QString();
//qDebug() << "DataProxy_SQLite::getYearsOperating: -1" << QT_ENDL;
bool sqlOk = query.exec(queryString);
if (sqlOk)
{
//qDebug() << "DataProxy_SQLite::getYearsOperating: sqlOk = true" << QT_ENDL;
while (query.next())
{
if (query.isValid())
{
year = (query.value(0)).toString();
//qDebug() << "DataProxy_SQLite::getYearsOperating: year=" << year << QT_ENDL;
years << year;
year.clear();
}
else
{
//qDebug() << "DataProxy_SQLite::getYearsOperating: NOT VALID" << QT_ENDL;
}
}
//qDebug() << "DataProxy_SQLite::getYearsOperating: END OK - " << QString::number(years.size())<< QT_ENDL;
query.finish();
//return years;
if (years.length()>0)
{
years.sort();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::getYearsOperating: sqlOk = false" << QT_ENDL;
}
return years;
}
void DataProxy_SQLite::compressDB()
{
db->compress();
}
bool DataProxy_SQLite::unMarkAllQSO()
{
return db->unMarkAllQSO();
}
bool DataProxy_SQLite::lotwSentQueue(const QDate &_updateDate, const int _currentLog)
{// Mark LOTW QSL SENT as Q (Queued)
// If currentLog <0 ALL the QSO of the log will be queued
//qDebug() << "DataProxy_SQLite::lotwSentQueue: Date:" << _updateDate << " /" << QString::number(_currentLog) << QT_ENDL;
QString queryString;
if (_currentLog<1)
{
queryString = QString("UPDATE log SET lotw_qsl_sent = 'Q', lotw_qslsdate = '%1' WHERE lotw_qsl_sent != 'Y' AND lotw_qsl_sent != 'N' AND lotw_qsl_sent != 'R' AND lotw_qsl_sent != 'I' AND lotw_qsl_sent != 'Q'").arg(util->getDateSQLiteStringFromDate(_updateDate));
}
else
{
queryString = QString("UPDATE log SET lotw_qsl_sent = 'Q', lotw_qslsdate = '%1' WHERE lognumber = '%2' AND lotw_qsl_sent != 'Y' AND lotw_qsl_sent != 'N' AND lotw_qsl_sent != 'R' AND lotw_qsl_sent != 'I' AND lotw_qsl_sent != 'Q'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_currentLog);
}
QSqlQuery query;
bool sqlOK = query.exec(queryString);
query.finish();
if (sqlOK)
{
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
return false;
}
bool DataProxy_SQLite::lotwSentYes(const QDate &_updateDate, const int _currentLog, const QString &_station)
{// Mark LOTW QSL SENT as Q (Queued)
// If currentLog <0 ALL the QSO of the log will be queued
//qDebug() << "DataProxy_SQLite::lotwSentQueue: " << QString::number(_currentLog) << QT_ENDL;
QString queryString;
if (_currentLog<1)
{
if (_station == "ALL")
{
queryString = QString("UPDATE log SET lotw_qsl_sent = 'Y', lotw_qslsdate = '%1' WHERE lotw_qsl_sent == 'Q'");
}
else
{
queryString = QString("UPDATE log SET lotw_qsl_sent = 'Y', lotw_qslsdate = '%1' WHERE lotw_qsl_sent == 'Q' AND station_callsign='%2'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_station);
}
}
else
{
if (_station == "ALL")
{
queryString = QString("UPDATE log SET lotw_qsl_sent = 'Y', lotw_qslsdate = '%1' WHERE lognumber = '%2' AND lotw_qsl_sent == 'Q'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_currentLog);
}
else
{
queryString = QString("UPDATE log SET lotw_qsl_sent = 'Y', lotw_qslsdate = '%1' WHERE lognumber = '%2' AND lotw_qsl_sent == 'Q' AND station_callsign='%3'").arg(util->getDateSQLiteStringFromDate(_updateDate)).arg(_currentLog).arg(_station);
}
}
QSqlQuery query;
bool sqlOK = query.exec(queryString);
query.finish();
if (sqlOK)
{
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
return false;
}
bool DataProxy_SQLite::lotwSentQSOs(const QList &_qsos)
{
//qDebug() << " DataProxy_SQLite::lotwSentQSOs" << QString::number(_qsos.count()) << QT_ENDL;
if (_qsos.count() < 1)
{
return true;
}
QString queryString;
bool sqlOK;
QSqlQuery query;
for (int i = 0; i< _qsos.count(); i++)
{
//qDebug() << " DataProxy_SQLite::lotwSentQSOs: updating QSO: " << QString::number(_qsos.at(i)) << QT_ENDL;
//queryString = QString("UPDATE log SET lotw_qsl_sent = 'Y', lotw_qslsdate = '%1' WHERE id='%2'").arg((QDate::currentDate()).toString("yyyy-MM-dd")).arg(QString::number(_qsos.at(i)));
queryString = QString("UPDATE log SET lotw_qsl_sent = 'Y', lotw_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::lotwSentQSOs: exec: " << query.lastQuery() << QT_ENDL;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << " DataProxy_SQLite::lotwSentQSOs: END FALSE" << QT_ENDL;
return false;
}
}
//qDebug() << " DataProxy_SQLite::lotwSentQSOs: END TRUE" << QT_ENDL;
return true;
}
int DataProxy_SQLite::lotwUpdateQSLReception (const QString &_call, const QDateTime &_dateTime, const QString &_band, const QString &_mode, const QDate &_qslrdate)
{ //Returns the QSO id updated or -1 if none was updated.
//qDebug() << " DataProxy_SQLite::lotwUpdateQSLReception: " << _call << "/" << util->getDateTimeSQLiteStringFromDateTime(_dateTime) << "/" <<_band <<"/"<<_mode << "/" << util->getADIFDateFromQDate(_qslrdate) << endl ;
int bandid = getIdFromBandName(_band);
int modeid = getIdFromModeName(_mode);
QString qso_date;
qso_date = util->getDateTimeSQLiteStringFromDateTime(_dateTime);
QString queryString;
//queryString = QString("SELECT id, lotw_qsl_rcvd FROM log WHERE call='%1' AND qso_date='%2' AND bandid='%4' AND modeid='%5'").arg(_call).arg(qso_date).arg(bandid).arg(modeid);
queryString = QString("SELECT id, lotw_qsl_rcvd FROM log WHERE call='%1' AND qso_date='%2' AND bandid='%4' AND modeid='%5'").arg(_call).arg(qso_date).arg(bandid).arg(modeid);
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int id = (query.value(0)).toInt();
QString _lotwQSLReceived = (query.value(1).toString());
if (( id > 0) && (_lotwQSLReceived!="Y"))
{
query.finish();
//QString qslsdate = (QDate::fromString(_qslsdate, "yyyyMMdd")).toString("yyyy-MM-dd");
//QString qslrdate = (QDate::fromString(_qslrdate, "yyyyMMdd")).toString("yyyy-MM-dd");
queryString = QString("UPDATE log SET lotw_qsl_rcvd = 'Y', lotw_qslrdate = '%1' WHERE id='%2'").arg(util->getDateSQLiteStringFromDate(_qslrdate)).arg(QString::number(id));
sqlOK = query.exec(queryString);
query.finish();
if (sqlOK)
{
//qDebug() << "DataProxy_SQLite::lotwUpdateQSLReception: Modified Id: " << QString::number(id) << QT_ENDL;
return id;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::lotwUpdateQSLReception: SQL ERROR" << QT_ENDL;
return -4;
}
}
else
{
//qDebug() << "DataProxy_SQLite::lotwUpdateQSLReception ID Not found" << QT_ENDL;
query.finish();
return -5;
}
}
else if (query.lastError().nativeErrorCode() == -1)
{
//qDebug() << "DataProxy_SQLite::lotwUpdateQSLReception QSO not found " << query.lastQuery() << QT_ENDL;
return -1;
}
else
{
//qDebug() << "DataProxy_SQLite::lotwUpdateQSLReception Unknown error " << query.lastQuery() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::lotwUpdateQSLReception Error: " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::lotwUpdateQSLReception Error: " << QString::number(query.lastError().nativeErrorCode()) << QT_ENDL;
query.finish();
return -3;
}
}
else
{
//qDebug() << "DataProxy_SQLite::lotwUpdateQSLReception Query error: " << query.lastQuery() << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
query.finish();
return -100;
}
QList DataProxy_SQLite::getQSOsListLoTWToSend(const QString &_stationCallsign, const QDate &_startDate, const QDate &_endDate, bool _justQueued, int _logN)
{
//qDebug() << "DataProxy_SQLite::getQSOsListLoTWToSend Call/Start/end: " << _stationCallsign << _startDate.toString("yyyyMMdd") << "/" << _endDate.toString("yyyyMMdd") << QT_ENDL;
QList 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::getQSOsListLoTWToSend justQueued TRUE" << QT_ENDL;
_query_justQueued = QString("lotw_qsl_sent='Q'");
}
else
{
//qDebug() << "DataProxy_SQLite::getQSOsListLoTWToSend justQueued FALSE" << QT_ENDL;
_query_justQueued = QString("lotw_qsl_sent!='1'");
}
QString _query_logNumber;
if (doesThisLogExist (_logN))
{
_query_logNumber = QString(" AND lognumber='%1'").arg(_logN);
}
else
{
_query_logNumber.clear ();
}
queryString = QString("SELECT id, qso_date FROM log WHERE %1 AND %2 %3").arg(_queryST_string).arg(_query_justQueued).arg(_query_logNumber);
// queryString = QString("SELECT id, qso_date FROM log WHERE ") + _queryST_string + " AND " + _query_justQueued;
QSqlQuery query;
bool sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::getQSOsListLoTWToSend Query: " << query.lastQuery() << QT_ENDL;
if (sqlOK)
{
// //qDebug() << "DataProxy_SQLite::getQSOsListLoTWToSend Query: " << query.lastQuery() << QT_ENDL;
while ( (query.next())) {
if (query.isValid())
{
aux.clear();
aux = (query.value(1)).toString() ;
tmpDate = util->getDateFromSQliteString(aux);
//qDebug() << "DataProxy_SQLite::getQSOsListLoTWToSend QSO Date: " << aux << "/" << tmpDate.toString("yyyy-MM-dd") << QT_ENDL;
//tmpDate = QDate::fromString(aux, "yyyy-MM-dd");
if ((_startDate<=tmpDate) && _endDate>=tmpDate)
{
qsoList.append((query.value(0)).toInt());
}
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
qsoList.clear();
return qsoList;
}
query.finish();
qs.sort();
return qsoList;
}
QList DataProxy_SQLite::getQSOsListClubLogToSent(const QString &_stationCallsign, const QDate &_startDate, const QDate &_endDate, bool _justModified, int _logN)
{
//qDebug() << "DataProxy_SQLite::getQSOsListClubLogToSent Call/Start/end: " << _stationCallsign << _startDate.toString("yyyyMMdd") << "/" << _endDate.toString("yyyyMMdd") << QT_ENDL;
QList 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::getQSOsListClubLogToSent justQueued TRUE" << QT_ENDL;
_query_justModified = QString("clublog_qso_upload_status='M'");
}
else
{
//qDebug() << "DataProxy_SQLite::getQSOsListClubLogToSent justQueued FALSE" << QT_ENDL;
_query_justModified = QString("clublog_qso_upload_status!='M'");
}
//qDebug() << "DataProxy_SQLite::getQSOsListClubLogToSent logN: " << QString::number(_logN) << QT_ENDL;
QString _query_logNumber;
if (doesThisLogExist (_logN))
{
//qDebug() << "DataProxy_SQLite::getQSOsListClubLogToSent log DOES exist" << QT_ENDL;
_query_logNumber = QString(" AND lognumber='%1'").arg(_logN);
}
else
{
//qDebug() << "DataProxy_SQLite::getQSOsListClubLogToSent log DOES NOT exist" << QT_ENDL;
_query_logNumber.clear ();
}
queryString = QString("SELECT id, qso_date FROM log WHERE %1 AND %2 %3").arg(_queryST_string).arg(_query_justModified).arg(_query_logNumber);
//queryString = QString("SELECT id, qso_date FROM log WHERE ") + _queryST_string + " AND " + _query_justModified;
QSqlQuery query;
bool sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::getQSOsListClubLogToSent Query: " << query.lastQuery() << QT_ENDL;
if (sqlOK)
{
// //qDebug() << "DataProxy_SQLite::getQSOsListClubLogToSent Query: " << query.lastQuery() << QT_ENDL;
while ( (query.next())) {
if (query.isValid())
{
aux.clear();
aux = (query.value(1)).toString() ;
tmpDate = util->getDateFromSQliteString(aux);
//qDebug() << "DataProxy_SQLite::getQSOsListClubLogToSent QSO Date: " << aux << "/" << tmpDate.toString("yyyy-MM-dd") << QT_ENDL;
//tmpDate = QDate::fromString(aux, "yyyy-MM-dd");
if ((_startDate<=tmpDate) && _endDate>=tmpDate)
{
//qDebug() << "DataProxy_SQLite::getQSOsListClubLogToSent Adding: " << QString::number((query.value(0)).toInt()) << QT_ENDL;
qsoList.append((query.value(0)).toInt());
}
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
qsoList.clear();
return qsoList;
}
query.finish();
qs.sort();
//qDebug() << "DataProxy_SQLite::getQSOsListClubLogToSent Returning: #" << QString::number(qsoList.length()) << QT_ENDL;
return qsoList;
}
QList 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") << QT_ENDL;
QList 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" << QT_ENDL;
_query_justModified = QString("eqsl_qsl_sent='Q'");
}
else
{
//qDebug() << "DataProxy_SQLite::getQSOsListEQSLToSent justQueued FALSE" << QT_ENDL;
_query_justModified = QString("eqsl_qsl_sent!='M'");
}
/* Modify accordingly to add log number support
QString _query_logNumber;
if (doesThisLogExist (_logN))
{
_query_logNumber = QString(" AND lognumber='%1'").arg(_logN);
}
else
{
_query_logNumber.clear ();
}
queryString = QString("SELECT id, qso_date FROM log WHERE %1 AND %2 '%3'").arg(_queryST_string).arg(_query_justQueued).arg(_query_logNumber);
*/
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() << QT_ENDL;
if (sqlOK)
{
// //qDebug() << "DataProxy_SQLite::getQSOsListEQSLToSent Query: " << query.lastQuery() << QT_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") << QT_ENDL;
//tmpDate = QDate::fromString(aux, "yyyy-MM-dd");
if ((_startDate<=tmpDate) && _endDate>=tmpDate)
{
qsoList.append((query.value(0)).toInt());
}
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
qsoList.clear();
return qsoList;
}
query.finish();
qs.sort();
return qsoList;
}
QList DataProxy_SQLite::getQSOsListQRZCOMToSent(const QString &_stationCallsign, const QDate &_startDate, const QDate &_endDate, bool _justModified)
{
//qDebug() << "DataProxy_SQLite::QList getQSOsListQRZCOMToSent(const QString &_stationCallsign, const QDate &_startDate, const QDate &_endDate, bool _justModified=true); Call/Start/end: " << _stationCallsign << _startDate.toString("yyyyMMdd") << "/" << _endDate.toString("yyyyMMdd") << QT_ENDL;
QList 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::getQSOsListQRZCOMToSent justQueued TRUE" << QT_ENDL;
_query_justModified = QString("qrzcom_qso_upload_status='M'");
}
else
{
//qDebug() << "DataProxy_SQLite::getQSOsListQRZCOMToSent justQueued FALSE" << QT_ENDL;
_query_justModified = QString("qrzcom_qso_upload_status!='-'");
}
/*
QString _query_logNumber;
if (doesThisLogExist (_logN))
{
_query_logNumber = QString(" AND lognumber='%1'").arg(_logN);
}
else
{
_query_logNumber.clear ();
}
queryString = QString("SELECT id, qso_date FROM log WHERE %1 AND %2 %3").arg(_queryST_string).arg(_query_justModified).arg(_query_logNumber);
*/
queryString = QString("SELECT id, qso_date FROM log WHERE ") + _queryST_string + " AND " + _query_justModified;
QSqlQuery query;
bool sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::getQSOsListQRZCOMToSent Query: " << query.lastQuery() << QT_ENDL;
if (sqlOK)
{
// //qDebug() << "DataProxy_SQLite::getQSOsListQRZCOMToSent Query: " << query.lastQuery() << QT_ENDL;
while ( (query.next())) {
if (query.isValid())
{
aux.clear();
aux = (query.value(1)).toString() ;
tmpDate = util->getDateFromSQliteString(aux);
//qDebug() << "DataProxy_SQLite::getQSOsListQRZCOMToSent QSO Date: " << aux << "/" << tmpDate.toString("yyyy-MM-dd") << QT_ENDL;
//tmpDate = QDate::fromString(aux, "yyyy-MM-dd");
if ((_startDate<=tmpDate) && _endDate>=tmpDate)
{
qsoList.append((query.value(0)).toInt());
}
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
qsoList.clear();
return qsoList;
}
query.finish();
qs.sort();
return qsoList;
}
QList DataProxy_SQLite::getQSOsListToBeExported(const QString &_stationCallsign, const QDate &_startDate, const QDate &_endDate)
{
//qDebug() << Q_FUNC_INFO << ": Call/Start/end: " << _stationCallsign << _startDate.toString("yyyyMMdd") << "/" << _endDate.toString("yyyyMMdd") << QT_ENDL;
QList 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=''");
}
/* Modify accordingly to add log number support
QString _query_logNumber;
if (doesThisLogExist (_logN))
{
_query_logNumber = QString(" AND lognumber='%1'").arg(_logN);
}
else
{
_query_logNumber.clear ();
}
queryString = QString("SELECT id, qso_date FROM log WHERE %1 AND %2 '%3'").arg(_queryST_string).arg(_query_justQueued).arg(_logN);
*/
queryString = QString("SELECT id, qso_date FROM log WHERE ") + _queryST_string ;
QSqlQuery query;
bool sqlOK = query.exec(queryString);
//qDebug() << Q_FUNC_INFO << ": Query: " << query.lastQuery() << QT_ENDL;
if (sqlOK)
{
// //qDebug() << Q_FUNC_INFO << ": Query: " << query.lastQuery() << QT_ENDL;
while ( (query.next())) {
if (query.isValid())
{
aux.clear();
aux = (query.value(1)).toString() ;
tmpDate = util->getDateFromSQliteString(aux);
//qDebug() << Q_FUNC_INFO << ": QSO Date: " << aux << "/" << tmpDate.toString("yyyy-MM-dd") << QT_ENDL;
//tmpDate = QDate::fromString(aux, "yyyy-MM-dd");
if ((_startDate<=tmpDate) && _endDate>=tmpDate)
{
qsoList.append((query.value(0)).toInt());
}
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
qsoList.clear();
return qsoList;
}
query.finish();
qs.sort();
return qsoList;
}
QList 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") << QT_ENDL;
QList 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" << QT_ENDL;
_query_justQueued = QString("eqsl_qsl_sent='Q'");
}
else
{
//qDebug() << "DataProxy_SQLite::getQSOsListeQSLNotSent justQueued FALSE" << QT_ENDL;
_query_justQueued = QString("eqsl_qsl_sent!='1'");
}
/* Modify accordingly to add log number support
QString _query_logNumber;
if (doesThisLogExist (_logN))
{
_query_logNumber = QString(" AND lognumber='%1'").arg(_logN);
}
else
{
_query_logNumber.clear ();
}
queryString = QString("SELECT id, qso_date FROM log WHERE %1 AND %2 '%3'").arg(_queryST_string).arg(_query_justQueued).arg(_logN);
*/
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() << QT_ENDL;
if (sqlOK)
{
// //qDebug() << "DataProxy_SQLite::getQSOsListeQSLNotSent Query: " << query.lastQuery() << QT_ENDL;
while ( (query.next())) {
if (query.isValid())
{
aux.clear();
aux = (query.value(1)).toString() ;
tmpDate = util->getDateFromSQliteString(aux);
//qDebug() << "DataProxy_SQLite::getQSOsListLoTWToSend QSO Date: " << aux << "/" << tmpDate.toString("yyyy-MM-dd") << QT_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().nativeErrorCode(), 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) << QT_ENDL;
QStringList result;
result.clear();
//getNameFromBandId
QSqlQuery query;
QString queryString = QString("SELECT call, qso_date, bandid, modeid FROM log WHERE id='%0'").arg(_id);
bool sqlOk = query.exec(queryString);
if (sqlOk)
{
if (query.next())
{
if (query.isValid())
{
QString call = query.value(0).toString();
QString date = query.value(1).toString();
//QString date = util->getDateTimeFromSQLiteString(query.value(1).toString());
//QString time = query.value(2).toString();
QString bandid = query.value(2).toString();
QString modeid = query.value(3).toString();
query.finish();
//qDebug() << "DataProxy_SQLite::getQSODetailsForLoTWDownload - date: " << date << QT_ENDL;
//qDebug() << "DataProxy_SQLite::getQSODetailsForLoTWDownload - time: " << time << QT_ENDL;
//getDateTimeSQLiteStringFromDateTime
//QString dateTime = (QDateTime::fromString(date, "yyyy-MM-dd hh:mm:ss")).toString("yyyy-MM-dd hh:mm");
QString dateTime = (util->getDateTimeFromSQLiteString(date)).toString("yyyy-MM-dd hh:mm");
bandid = getNameFromBandId(bandid.toInt());
modeid = getNameFromModeId(modeid.toInt());
result.append(call);
result.append(dateTime);
result.append(bandid);
result.append(modeid);
//qDebug() << "DataProxy_SQLite::getQSODetailsForLoTWDownload - END: call: " << call << QT_ENDL;
return result;
}
//qDebug() << "DataProxy_SQLite::getQSODetailsForLoTWDownload - END: no valid " << QT_ENDL;
}
query.finish();
//qDebug() << "DataProxy_SQLite::getQSODetailsForLoTWDownload - END: no next " << QT_ENDL;
return result;
}
else
{
//qDebug() << "DataProxy_SQLite::getQSODetailsForLoTWDownload - END: SQL NOK " << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return result;
}
}
int DataProxy_SQLite::getQSOonYear(const int _year, const int _logNumber)
{
//qDebug() << "DataProxy_SQLite::getQSOonYear: " << QString::number(_year) << "/" << QString::number(_logNumber) << QT_ENDL;
QSqlQuery query;
QString queryString;
bool sqlOK;
if (_logNumber < 0)
{
queryString = QString("SELECT COUNT (DISTINCT id) FROM log WHERE qso_date LIKE '%1%'").arg(_year);
}
else
{
queryString = QString("SELECT COUNT (DISTINCT id) FROM log where lognumber='%1' AND qso_date LIKE '%2%'").arg(_logNumber).arg(_year);
}
sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::getQSOonYear: queryString: " << queryString << QT_ENDL;
if (sqlOK)
{
query.next();
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::getQSOonYear: " << QString::number((query.value(0)).toInt()) << QT_ENDL;
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
//qDebug() << "DataProxy_SQLite::getQSOonYear: 0" << QT_ENDL;
query.finish();
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::getDXCConYear: Query error" << QT_ENDL;
query.finish();
return 0;
}
}
int DataProxy_SQLite::getDXCConYear(const int _year, const int _logNumber)
{
//qDebug() << "DataProxy_SQLite::getDXCConYear: " << QString::number(_year) << "/" << QString::number(_logNumber) << QT_ENDL;
QSqlQuery query;
QString queryString;
bool sqlOK;
if (_logNumber < 0)
{
queryString = QString("SELECT COUNT (DISTINCT dxcc) FROM log WHERE dxcc>'0' AND qso_date LIKE '%1%'").arg(_year);
}
else
{
queryString = QString("SELECT COUNT (DISTINCT dxcc) FROM log WHERE dxcc>'0' AND lognumber='%1' AND qso_date LIKE '%2%'").arg(_logNumber).arg(_year);
}
sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::getDXCConYear: queryString: " << queryString << QT_ENDL;
if (sqlOK)
{
query.next();
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::getDXCConYear: " << QString::number((query.value(0)).toInt()) << QT_ENDL;
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
//qDebug() << "DataProxy_SQLite::getDXCConYear: 0" << QT_ENDL;
query.finish();
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::getDXCConYear: Query error" << QT_ENDL;
query.finish();
return 0;
}
}
int DataProxy_SQLite::getCQzonYear(const int _year, const int _logNumber)
{
//qDebug() << "DataProxy_SQLite::getCQzonYear: " << QString::number(_year) << QT_ENDL;
QSqlQuery query;
QString queryString;
bool sqlOK;
if (_logNumber < 0)
{
queryString = QString("SELECT COUNT (DISTINCT cqz) FROM log where qso_date LIKE '%1%' AND cqz>'0' AND cqz < '41'").arg(_year);
}
else
{
queryString = QString("SELECT COUNT (DISTINCT cqz) FROM log where lognumber='%1' AND cqz>'0' AND cqz<'41' AND qso_date LIKE '%2%'").arg(_logNumber).arg(_year);
}
sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::getCQzonYear: queryString: " << queryString << QT_ENDL;
if (sqlOK)
{
query.next();
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::getCQzonYear: " << QString::number((query.value(0)).toInt()) << QT_ENDL;
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
//qDebug() << "DataProxy_SQLite::getCQzonYear: 0" << QT_ENDL;
query.finish();
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::getCQzonYear: Query error" << QT_ENDL;
query.finish();
return 0;
}
}
int DataProxy_SQLite::getQSOsWithDXCC(const int _dxcc, const int _logNumber)
{
//qDebug() << "DataProxy_SQLite::getQSOsWithDXCC: " << QString::number(_dxcc) << QT_ENDL;
QSqlQuery query;
QString queryString;
bool sqlOK;
if (_logNumber < 0)
{
queryString = QString("SELECT COUNT (DISTINCT id) FROM log where dxcc LIKE '%1'").arg(_dxcc);
}
else
{
queryString = QString("SELECT COUNT (DISTINCT id) FROM log where lognumber='%1' AND dxcc LIKE '%2'").arg(_logNumber).arg(_dxcc);
}
sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::getQSOsWithDXCC: queryString: " << queryString << QT_ENDL;
if (sqlOK)
{
query.next();
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::getQSOsWithDXCC: " << QString::number((query.value(0)).toInt()) << QT_ENDL;
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
//qDebug() << "DataProxy_SQLite::getQSOsWithDXCC: 0" << QT_ENDL;
query.finish();
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::getQSOsWithDXCC: Query error" << QT_ENDL;
query.finish();
return 0;
}
}
int DataProxy_SQLite::getQSOsAtHour(const int _hour, const int _log)
{
//qDebug() << "DataProxy_SQLite::getQSOsAtHour: " << QString::number(_hour) << QT_ENDL;
QSqlQuery query;
QString queryString;
bool sqlOK;
QString aux = QString();
if (_hour < 10)
{
aux = "0" + QString::number(_hour);
}
else
{
aux = QString::number(_hour);
}
if (_log < 0)
{
queryString = QString("SELECT COUNT(DISTINCT id) FROM log WHERE qso_date LIKE '% %1:%'").arg(aux);
}
else
{
queryString = QString("SELECT COUNT(DISTINCT id) FROM log WHERE lognumber='%1' AND qso_date LIKE '% %2:%'").arg(_log).arg(aux);
}
sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::getQSOsAtHour: queryString: " << queryString << QT_ENDL;
if (sqlOK)
{
query.next();
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::getQSOsAtHour: " << QString::number((query.value(0)).toInt()) << QT_ENDL;
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
//qDebug() << "DataProxy_SQLite::getQSOsAtHour: 0" << QT_ENDL;
query.finish();
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::getQSOsAtHour: Query error" << QT_ENDL;
query.finish();
return 0;
}
}
int DataProxy_SQLite::getQSOsAtHourOnBand(const int _hour, const int _band, const int _log)
{
//qDebug() << "DataProxy_SQLite::getQSOsAtHourOnBand: " << QString::number(_hour) << QT_ENDL;
QSqlQuery query;
QString queryString;
bool sqlOK;
QString aux = QString();
if (_hour < 10)
{
aux = "0" + QString::number(_hour);
}
else
{
aux = QString::number(_hour);
}
if (_log < 0)
{
queryString = QString("SELECT COUNT(DISTINCT id) FROM log WHERE qso_date LIKE '% %1:%' AND bandid='%2'").arg(aux).arg(_band);
}
else
{
queryString = QString("SELECT COUNT(DISTINCT id) FROM log WHERE lognumber='%1' AND qso_date LIKE '% %2:%' AND bandid='%3'").arg(_log).arg(aux).arg(_band);
}
sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::getQSOsAtHourOnBand: queryString: " << queryString << QT_ENDL;
if (sqlOK)
{
query.next();
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::getQSOsAtHourOnBand: " << QString::number((query.value(0)).toInt()) << QT_ENDL;
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
//qDebug() << "DataProxy_SQLite::getQSOsAtHourOnBand: 0" << QT_ENDL;
query.finish();
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::getQSOsAtHourOnBandç: Query error" << QT_ENDL;
query.finish();
return 0;
}
}
int DataProxy_SQLite::getQSOsOnMonth(const int _month, const int _log)
{
//qDebug() << "DataProxy_SQLite::getgetQSOsOnMonth: " << QString::number(_month) << QT_ENDL;
QSqlQuery query;
QString queryString;
bool sqlOK;
QString aux = QString();
if (_month < 10)
{
aux = "0" + QString::number(_month);
}
else
{
aux = QString::number(_month);
}
if (_log < 0)
{
queryString = QString("SELECT COUNT(DISTINCT id) FROM log WHERE qso_date LIKE '%-%1-%'").arg(aux);
}
else
{
queryString = QString("SELECT COUNT(DISTINCT id) FROM log WHERE lognumber='%1' AND qso_date LIKE '%-%2-%'").arg(_log).arg(aux);
}
sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::getQSOsAtHour: queryString: " << queryString << QT_ENDL;
if (sqlOK)
{
query.next();
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::getQSOsAtHour: " << QString::number((query.value(0)).toInt()) << QT_ENDL;
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
//qDebug() << "DataProxy_SQLite::getQSOsAtHour: 0" << QT_ENDL;
query.finish();
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::getQSOsAtHour: Query error" << QT_ENDL;
query.finish();
return 0;
}
}
bool DataProxy_SQLite::updateQSONumberPerLog()
{
//qDebug() << Q_FUNC_INFO << QT_ENDL;
QSqlQuery query;
QString queryString;
bool sqlOK;
QList _logsInLogs;
_logsInLogs.clear();
queryString = QString("SELECT id FROM logs");
sqlOK = query.exec(queryString);
if (sqlOK)
{
while(query.next())
{
if (query.isValid())
{
if ( (query.value(0)).toInt() >= 1)
{
_logsInLogs.append((query.value(0)).toInt());
}
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << Q_FUNC_INFO << " - TRUE2" << QT_ENDL;
query.finish();
return false;
}
query.finish();
foreach(int i, _logsInLogs)
{
int _qsos = getHowManyQSOInLog(i);
if (_qsos>0)
{
queryString = QString("UPDATE logs set logtypen = '%1' WHERE id = '%2'").arg(_qsos).arg(i);
sqlOK = query.exec(queryString);
if (!sqlOK)
{
query.finish();
return false;
}
query.finish();
}
}
return true;
}
bool DataProxy_SQLite::newDXMarathon(const int _dxcc, const int _cq, const int _year, const int _logNumber)
{
//qDebug() << "DataProxy_SQLite::newDXMarathon" << QT_ENDL;
QSqlQuery query;
QString queryString;
bool sqlOK;
bool existingDXCC = false;
bool existingCQz = false;
queryString = QString("SELECT dxcc, cqz FROM log WHERE (lognumber='%1' AND qso_date LIKE'%%2%') AND (dxcc ='%3' OR cqz ='%4')").arg(_logNumber).arg(_year).arg(_dxcc).arg(_cq);
sqlOK = query.exec(queryString);
if (sqlOK)
{
while(query.next())
{
if (query.isValid())
{
if ( (query.value(0)).toInt() == _dxcc)
{
//qDebug() << "DataProxy_SQLite::newDXMarathon - Existing DXCC" << QT_ENDL;
existingDXCC = true;
}
if ( (query.value(1)).toInt() == _cq)
{
//qDebug() << "DataProxy_SQLite::newDXMarathon - Existing CQz" << QT_ENDL;
existingCQz = true;
}
}
}
if (existingDXCC && existingCQz)
{
//qDebug() << "DataProxy_SQLite::newDXMarathon - FALSE" << QT_ENDL;
query.finish();
return false;
}
else
{
//qDebug() << "DataProxy_SQLite::newDXMarathon - TRUE1" << QT_ENDL;
query.finish();
return true;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::newDXMarathon - TRUE2" << QT_ENDL;
query.finish();
return true; // It is an error inthe query but Work First Worry Later, let us work that QSO.
}
}
QStringList DataProxy_SQLite::getContestNames()
{
//qDebug() << "DataProxy_SQLite::getContestNames() " << QT_ENDL;
QStringList contests = QStringList();
QSqlQuery query;
QString queryString;
bool sqlOK;
queryString = QString("SELECT DISTINCT name from supportedcontests ORDER BY id ASC");
sqlOK = query.exec(queryString);
if (sqlOK)
{
while(query.next())
{
if (query.isValid())
{
queryString = (query.value(0)).toString();
//qDebug() << "DataProxy_SQLite::getContestNames: " << queryString << QT_ENDL;
contests.append(queryString);
}
else
{
query.finish();
return QStringList();
}
}
query.finish();
contests.sort();
return contests;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QStringList();
}
//return QStringList();
}
QStringList DataProxy_SQLite::getContestCat(const int _catn)
{
QStringList contests = QStringList();
QSqlQuery query;
QString queryString;
bool sqlOK;
switch (_catn) {
case 1:
queryString = QString("SELECT DISTINCT name from contestcatoperator ORDER BY id ASC");
break;
case 2:
queryString = QString("SELECT DISTINCT name from contestcatassisted ORDER BY id ASC");
break;
case 3:
queryString = QString("SELECT DISTINCT name from contestcatpower ORDER BY id ASC");
break;
case 4:
queryString = QString("SELECT DISTINCT name from contestcatband ORDER BY id ASC");
break;
case 5:
queryString = QString("SELECT DISTINCT name from contestcatoverlay ORDER BY id ASC");
break;
case 6:
queryString = QString("SELECT DISTINCT name from contestcatmode ORDER BY id ASC");
break;
default:
return QStringList();
//break;
}
sqlOK = query.exec(queryString);
if (sqlOK)
{
while(query.next())
{
if (query.isValid())
{
queryString = (query.value(0)).toString();
contests.append(queryString);
}
else
{
query.finish();
return QStringList();
}
}
query.finish();
return contests;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QStringList();
}
}
QStringList DataProxy_SQLite::getContestOverlays()
{
//qDebug() << "DataProxy_SQLite::getContestOverlays: "<< QT_ENDL;
QStringList contests = QStringList();
QSqlQuery query;
QString queryString;
bool sqlOK;
queryString = QString("SELECT DISTINCT name from contestcatoverlay ORDER BY id ASC");
sqlOK = query.exec(queryString);
if (sqlOK)
{
while(query.next())
{
if (query.isValid())
{
queryString = (query.value(0)).toString();
//qDebug() << "DataProxy_SQLite::getContestOverlays: " << queryString << QT_ENDL;
contests.append(queryString);
}
else
{
query.finish();
return QStringList();
}
}
query.finish();
return contests;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QStringList();
}
}
QStringList DataProxy_SQLite::getPropModeList()
{
//qDebug() << "DataProxy_SQLite::getPropModeLists" << QT_ENDL;
QString aux = QString();
QStringList qs;
qs.clear();
QString queryString = QString("SELECT id, shortname, name FROM prop_mode_enumeration ORDER BY name");
QSqlQuery query;
bool sqlOK = query.exec(queryString);
QString num;
if (sqlOK)
{
QString translatedValue = QString();
QString valueToTranslate = QString();
while ( (query.next())) {
if (query.isValid())
{
valueToTranslate = (query.value(2)).toString();
if (valueToTranslate == "Aircraft Scatter")
{
translatedValue = tr("Aircraft Scatter", "Common term in hamradio, do not translate if not sure");
}
else if(valueToTranslate == "Aurora")
{
translatedValue = tr("Aurora");
}
else if(valueToTranslate == "Aurora-E")
{
translatedValue = tr("Aurora-E");
}
else if(valueToTranslate == "Back scatter")
{
translatedValue = tr("Back scatter", "Common term in hamradio, do not translate if not sure");
}
else if(valueToTranslate == "Earth-Moon-Earth")
{
translatedValue = tr("Earth-Moon-Earth");
}
else if(valueToTranslate == "Sporadic E")
{
translatedValue = tr("Sporadic E");
}
else if(valueToTranslate == "Field Aligned Irregularities")
{
translatedValue = tr("Field Aligned Irregularities", "Common term in hamradio, do not translate if not sure");
}
else if(valueToTranslate == "F2 Reflection")
{
translatedValue = tr("F2 Reflection", "Common term in hamradio, do not translate if not sure");
}
else if(valueToTranslate == "Internet-assisted")
{
translatedValue = tr("Internet-assisted");
}
else if(valueToTranslate == "Ionoscatter")
{
translatedValue = tr("Ionoscatter", "Common term in hamradio, do not translate if not sure");
}
else if(valueToTranslate == "Meteor scatter")
{
translatedValue = tr("Meteor scatter", "Common term in hamradio, do not translate if not sure");
}
else if(valueToTranslate == "Terrestrial or atmospheric repeater or transponder")
{
translatedValue = tr("Terrestrial or atmospheric repeater or transponder");
}
else if(valueToTranslate == "Rain scatter")
{
translatedValue = tr("Rain scatter", "Common term in hamradio, do not translate if not sure");
}
else if(valueToTranslate == "Satellite")
{
translatedValue = tr("Satellite");
}
else if(valueToTranslate == "Trans-equatorial")
{
translatedValue = tr("Trans-equatorial", "Common term in hamradio, do not translate if not sure");
}
else if(valueToTranslate == "Tropospheric ducting")
{
translatedValue = tr("Tropospheric ducting", "Common term in hamradio, do not translate if not sure");
}
else if(valueToTranslate == "")
{
translatedValue = tr("");
}
else
{
translatedValue = valueToTranslate;
}
aux.clear();
num = (query.value(0)).toString();
if (num.toInt() <= 9)
{
num = "0" + num;
}
aux = num + " - " + (query.value(1)).toString() + " - " + translatedValue;
qs << aux;
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QStringList();
}
query.finish();
qs.sort();
return qs;
}
bool DataProxy_SQLite::clearSatList()
{
QSqlQuery query;
bool sqlOK = query.exec("DELETE FROM satellites");
if (sqlOK)
{
query.finish();
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
}
bool DataProxy_SQLite::addSatellite(const QString &_arrlId, const QString &_name, const QString &_downLink, const QString &_upLink, const QString &_mode, int id)
{
//qDebug() << "DataProxy_SQLite::addSatellite: " << QString::number(id) << QT_ENDL;
QSqlQuery query;
QString queryString;
if (id>0)
{
queryString = QString("UPDATE satellites set satarrlid = '%1', satname = '%2', uplink = '%3', downlink = '%4', satmode = '%5' WHERE id = '%6'").arg(_arrlId).arg(_name).arg(_upLink).arg(_downLink).arg(_mode).arg(id);
}
else
{
queryString = QString("INSERT INTO satellites (satarrlid, satname, uplink, downlink, satmode) VALUES ('%1', '%2', '%3', '%4', '%5')").arg(_arrlId).arg(_name).arg(_upLink).arg(_downLink).arg(_mode);
}
bool sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::addSatellite - query: " << query.lastQuery() << QT_ENDL;
if (sqlOK)
{
//qDebug() << "DataProxy_SQLite::addSatellite - TRUE" << QT_ENDL;
//qDebug() << "DataProxy_SQLite::addSatellite - TRUE - ERROR: " << QString::number(query.lastError().nativeErrorCode()) << QT_ENDL;
query.finish();
return true;
}
else
{
//qDebug() << "DataProxy_SQLite::addSatellite - FALSE" << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
}
int DataProxy_SQLite::getDBSatId(const QString &_arrlId)
{
//qDebug() << "DataProxy_SQLite::getDBSatId: " << _arrlId << QT_ENDL;
int aux = -1;
QString queryString = QString("SELECT id FROM satellites WHERE satarrlid='%1'").arg(_arrlId);
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
aux = query.value(0).toInt();
}
else
{
//qDebug() << "DataProxy_SQLite::getDBSatId: query not valid" << QT_ENDL;
query.finish();
}
}
else
{
//qDebug() << "DataProxy_SQLite::getSatelliteUplink: query failed: " << query.lastQuery() << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
}
//qDebug() << "DataProxy_SQLite::getSatelliteUplink: final: " << aux << QT_ENDL;
query.finish();
return aux;
}
QStringList DataProxy_SQLite::getSatellitesList()
{
//qDebug() << "DataProxy_SQLite::getSatellitesList" << QT_ENDL;
QString aux = QString();
QStringList qs;
qs.clear();
QString queryString = QString("SELECT satarrlid, satname FROM satellites");
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
while ( (query.next())) {
if (query.isValid())
{
aux.clear();
aux = (query.value(0)).toString() + " - " + (query.value(1)).toString();
qs << aux;
}
else
{
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QStringList();
}
query.finish();
qs.sort();
return qs;
}
QString DataProxy_SQLite::getSatelliteUplink(const QString &_sat)
{
//qDebug() << "DataProxy_SQLite::getSatelliteUplink: " << _sat << QT_ENDL;
QString aux = QString();
//QString aux2 = QString();
//double fr1, fr2, fr;
QString queryString = QString("SELECT uplink FROM satellites WHERE satarrlid='%1'").arg(_sat);
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
aux = query.value(0).toString();
aux = QString::number(getFreqFromRange(aux));
}
else
{
//qDebug() << "DataProxy_SQLite::getSatelliteUplink: query not valid" << QT_ENDL;
query.finish();
return QString();
}
}
else
{
//qDebug() << "DataProxy_SQLite::getSatelliteUplink: query failed: " << query.lastQuery() << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
//qDebug() << "DataProxy_SQLite::getSatelliteUplink: final: " << aux << QT_ENDL;
query.finish();
return aux;
}
QString DataProxy_SQLite::getSatelliteDownlink(const QString &_sat)
{
//qDebug() << "DataProxy_SQLite::getSatelliteDownlink: " << _sat << QT_ENDL;
QString aux = QString();
//QString aux2 = QString();
//double fr1, fr2, fr;
QString queryString = QString("SELECT downlink FROM satellites WHERE satarrlid='%1'").arg(_sat);
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
aux = query.value(0).toString();
aux = QString::number(getFreqFromRange(aux));
}
else
{
//qDebug() << "DataProxy_SQLite::getSatelliteDownlink: query not valid" << QT_ENDL;
query.finish();
return QString();
}
}
else
{
//qDebug() << "DataProxy_SQLite::getSatelliteDownlink: query failed: " << query.lastQuery() << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
//qDebug() << "DataProxy_SQLite::getSatelliteDownlink: final: " << aux << QT_ENDL;
query.finish();
return aux;
}
QString DataProxy_SQLite::getSatelliteMode(const QString &_sat)
{
QString aux = QString();
QString queryString = QString("SELECT satmode FROM satellites WHERE satarrlid='%1'").arg(_sat);
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
aux = query.value(0).toString();
query.finish();
if (aux.contains(','))
{ // Potentially somethink like: SSB,CW
// We select the first one
aux = aux.section(',', 0, 0); // We select the first package
}
}
else
{
//qDebug() << "DataProxy_SQLite::getSatelliteMode: query not valid" << QT_ENDL;
query.finish();
return QString();
}
}
else
{
//qDebug() << "DataProxy_SQLite::getSatelliteMode: query failed: " << query.lastQuery() << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
//qDebug() << "DataProxy_SQLite::getSatelliteMode: final: " << aux << QT_ENDL;
return aux;
}
QString DataProxy_SQLite::getSatelliteFullUplink(const QString &_sat)
{
//qDebug() << "DataProxy_SQLite::getSatelliteFullUplink: " << _sat << QT_ENDL;
QString aux = QString();
QString queryString = QString("SELECT uplink FROM satellites WHERE satarrlid='%1'").arg(_sat);
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
aux = query.value(0).toString();
}
else
{
//qDebug() << "DataProxy_SQLite::getSatelliteFullUplink: query not valid" << QT_ENDL;
query.finish();
return QString();
}
}
else
{
//qDebug() << "DataProxy_SQLite::getSatelliteFullUplink: query failed: " << query.lastQuery() << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
//qDebug() << "DataProxy_SQLite::getSatelliteFullUplink: final: " << aux << QT_ENDL;
query.finish();
return aux;
}
QString DataProxy_SQLite::getSatelliteFullDownlink(const QString &_sat)
{
//qDebug() << "DataProxy_SQLite::getSatelliteFullDownlink: " << _sat << QT_ENDL;
QString aux = QString();
//QString aux2 = QString();
//double fr1, fr2, fr;
QString queryString = QString("SELECT downlink FROM satellites WHERE satarrlid='%1'").arg(_sat);
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
aux = query.value(0).toString();
}
else
{
//qDebug() << "DataProxy_SQLite::getSatelliteFullDownlink: query not valid" << QT_ENDL;
query.finish();
return QString();
}
}
else
{
//qDebug() << "DataProxy_SQLite::getSatelliteFullDownlink: query failed: " << query.lastQuery() << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
//qDebug() << "DataProxy_SQLite::getSatelliteFullDownlink: final: " << aux << QT_ENDL;
query.finish();
return aux;
}
QString DataProxy_SQLite::getSatelliteFullMode(const QString &_sat)
{
QString aux = QString();
QString queryString = QString("SELECT satmode FROM satellites WHERE satarrlid='%1'").arg(_sat);
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
aux = query.value(0).toString();
query.finish();
}
else
{
//qDebug() << "DataProxy_SQLite::getSatelliteMode: query not valid" << QT_ENDL;
query.finish();
return QString();
}
}
else
{
//qDebug() << "DataProxy_SQLite::getSatelliteMode: query failed: " << query.lastQuery() << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
//qDebug() << "DataProxy_SQLite::getSatelliteMode: final: " << aux << QT_ENDL;
return aux;
}
QString DataProxy_SQLite::getSatelliteName(const QString &_sat)
{
//qDebug() << "DataProxy_SQLite::getSatelliteName: " << _sat << QT_ENDL;
QString aux = QString();
QString queryString = QString("SELECT satname FROM satellites WHERE satarrlid='%1'").arg(_sat);
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
aux = query.value(0).toString();
}
else
{
//qDebug() << "DataProxy_SQLite::getSatelliteName: query not valid" << QT_ENDL;
query.finish();
return QString();
}
}
else
{
//qDebug() << "DataProxy_SQLite::getSatelliteName: query failed: " << query.lastQuery() << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
//qDebug() << "DataProxy_SQLite::getSatelliteName: final: " << aux << QT_ENDL;
query.finish();
return aux;
}
QString DataProxy_SQLite::getSateliteArrlIdFromId(const int _id)
{
QString aux = QString();
QString queryString = QString("SELECT satarrlid FROM satellites WHERE id='%1'").arg(_id);
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
aux = query.value(0).toString();
query.finish();
}
else
{
//qDebug() << "DataProxy_SQLite::getSateliteArrlIdFromId: query not valid" << QT_ENDL;
query.finish();
return QString();
}
}
else
{
//qDebug() << "DataProxy_SQLite::getSateliteArrlIdFromId: query failed: " << query.lastQuery() << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
//qDebug() << "DataProxy_SQLite::getSateliteArrlIdFromId: final: " << aux << QT_ENDL;
return aux;
}
double DataProxy_SQLite::getFreqFromRange(QString _fr)
{ //May even receive: 145.900-146.00 and should return the mid in the range (145.950)
//qDebug() << "DataProxy_SQLite::getFreqFromRange: " << _fr << QT_ENDL;
QString fr1, fr2, aux;
double f1, f2;
fr1.clear();
fr2.clear();
f1 = 0.0;
f2 = 0.0;
aux.clear();
aux = _fr;
if (aux.contains(','))
{ // Potentially somethink like: 435.030-435.456,146.180
// We select the first range
//qDebug() << "DataProxy_SQLite::getFreqFromRange: has several freqs: " << aux << QT_ENDL;
aux = aux.section(',', 0, 0); // We select the first package
}
if (aux.contains('-')) // Potentially somethink like: 435.030-435.456
{
//qDebug() << "DataProxy_SQLite::getFreqFromRange: has several freqs: " << aux << QT_ENDL;
fr2 = aux.section('-', 1, 1); // We select the second freq
fr1 = aux.section('-', 0, 0); // We select the first freq
//qDebug() << "DataProxy_SQLite::getFreqFromRange: fr1: " << fr1 << QT_ENDL;
//qDebug() << "DataProxy_SQLite::getFreqFromRange: fr2: " << fr2 << QT_ENDL;
f1 = fr1.toDouble();
f2 = fr2.toDouble();
//qDebug() << "DataProxy_SQLite::getFreqFromRange: f1: " << QString::number(f1) << QT_ENDL;
//qDebug() << "DataProxy_SQLite::getFreqFromRange: f2: " << QString::number(f2) << QT_ENDL;
f1 = (f2 + f1)/2;
//qDebug() << "DataProxy_SQLite::getFreqFromRange: f1 after calc: " << QString::number(f1) << QT_ENDL;
}
else
{ // It is only one freq 145.950 so this is what must be returned
f1 = aux.toDouble();
}
//qDebug() << "DataProxy_SQLite::getFreqFromRange: Return: " << QString::number(f1) << QT_ENDL;
return f1;
}
QStringList DataProxy_SQLite::getQSLRcvdList()
{
//qDebug() << "DataProxy_SQLite::getQSLRcvdList" << QT_ENDL;
QString aux = QString();
QStringList qs;
qs.clear();
QString queryString = QString("SELECT shortname, name FROM qsl_rec_status");
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
QString translatedValue = QString();
QString valueToTranslate = QString();
while ( (query.next())) {
if (query.isValid())
{
valueToTranslate = (query.value(1)).toString();
if (valueToTranslate == "Yes")
{
translatedValue = tr("Yes");
}
else if(valueToTranslate == "No")
{
translatedValue = tr("No");
}
else if(valueToTranslate == "Requested")
{
translatedValue = tr("Requested");
}
else if(valueToTranslate == "Ignore/Invalid")
{
translatedValue = tr("Ignore/Invalid");
}
else if(valueToTranslate == "Validated")
{
translatedValue = tr("Validated");
}
else
{
translatedValue = valueToTranslate;
}
aux.clear();
aux = (query.value(0)).toString() + " - " + translatedValue;
qs << aux;
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QStringList();
}
query.finish();
return qs;
}
QStringList DataProxy_SQLite::getQSLSentList()
{
//qDebug() << "DataProxy_SQLite::getQSLSentList" << QT_ENDL;
QString aux = QString();
QStringList qs;
qs.clear();
QString queryString = QString("SELECT shortname, name FROM qsl_sent_status");
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
QString translatedValue = QString();
QString valueToTranslate = QString();
while ( (query.next()))
{
if (query.isValid())
{
valueToTranslate = (query.value(1)).toString();
if (valueToTranslate == "Yes")
{
translatedValue = tr("Yes");
}
else if(valueToTranslate == "No")
{
translatedValue = tr("No");
}
else if(valueToTranslate == "Requested")
{
translatedValue = tr("Requested");
}
else if(valueToTranslate == "Queued")
{
translatedValue = tr("Queued");
}
else if(valueToTranslate == "Ignore/Invalid")
{
translatedValue = tr("Ignore/Invalid");
}
else
{
translatedValue = valueToTranslate;
}
aux.clear();
aux = (query.value(0)).toString() + " - " + translatedValue;
qs << aux;
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QStringList();
}
query.finish();
return qs;
}
QStringList DataProxy_SQLite::getClubLogStatusList()
{
//qDebug() << "DataProxy_SQLite::getClubLogStatusList" << QT_ENDL;
QString aux = QString();
QStringList qs;
qs.clear();
QString queryString = QString("SELECT shortname, name FROM clublog_status");
QSqlQuery query;
bool sqlOK = query.exec(queryString);
QString translatedValue = QString();
QString valueToTranslate = QString();
if (sqlOK)
{
while ( (query.next())) {
if (query.isValid())
{
valueToTranslate = (query.value(1)).toString();
if (valueToTranslate == "Uploaded")
{
translatedValue = tr("Uploaded");
}
else if(valueToTranslate == "Do not upload")
{
translatedValue = tr("Do not upload");
}
else if(valueToTranslate == "Modified")
{
translatedValue = tr("Modified");
}
else
{
translatedValue = valueToTranslate;
}
aux.clear();
aux = (query.value(0)).toString() + " - " + translatedValue;
qs << aux;
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QStringList();
}
query.finish();
return qs;
}
QStringList DataProxy_SQLite::getQSLViaList()
{
//qDebug() << "DataProxy_SQLite::getQSLViaList" << QT_ENDL;
QString aux = QString();
QStringList qs;
qs.clear();
QString queryString = QString("SELECT shortname, name FROM qsl_via_enumeration");
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
QString translatedValue = QString();
QString valueToTranslate = QString();
while ( (query.next())) {
if (query.isValid())
{
valueToTranslate = (query.value(1)).toString();
if (valueToTranslate == "Bureau")
{
translatedValue = tr("Bureau", "Common term in hamradio, do not translate if not sure");
}
else if(valueToTranslate == "Direct")
{
translatedValue = tr("Direct");
}
else if(valueToTranslate == "Electronic")
{
translatedValue = tr("Electronic");
}
else if(valueToTranslate == "Manager")
{
translatedValue = tr("Manager", "Common term in hamradio, do not translate if not sure");
}
else
{
translatedValue = valueToTranslate;
}
aux.clear();
aux = (query.value(0)).toString() + " - " + translatedValue;
qs << aux;
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QStringList();
}
query.finish();
return qs;
}
bool DataProxy_SQLite::haveAtLeastOneLog()
{
//qDebug() << "DataProxy_SQLite::haveAtLeastOneLog()" << QT_ENDL;
QSqlQuery query;
bool sqlOK = query.exec("SELECT COUNT(id) from logs");
if (sqlOK)
{
query.next();
if (query.isValid())
{
if((query.value(0)).toInt()>0)
{
query.finish();
return true;
}
else
{
query.finish();
return false;
}
}
else
{
query.finish();
return false;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
//return false;
}
QStringList DataProxy_SQLite::getColumnNamesFromTableLog()
{
//qDebug() << "DataProxy_SQLite::getColumnNamesFromTableLog" << QT_ENDL;
return getColumnNamesFromTable("log");
}
QStringList DataProxy_SQLite::getColumnNamesFromTable(const QString &_tableName)
{
//qDebug() << "DataProxy_SQLite::getColumnNamesFromTable" << QT_ENDL;
return db->getColumnNamesFromTable(_tableName);
}
bool DataProxy_SQLite::setDXCCAwardStatus(const int _qsoId)
{
// If the band/mode/log is already confirmed: Return true
// If the band/mode/log is already worked and status worked: Return true
// If the band/mode/log is already worked and status confirmed: Update and Return true
// If not worked: Add and Return true
//qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: " << QString::number(_qsoId) << QT_ENDL;
if (_qsoId <= 0)
{
//qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: QSOid <=0 " << QString::number(_qsoId) << QT_ENDL;
return false;
}
QList values;
values.clear();
values << getBandModeDXCCCQZlogIDFromId(_qsoId);
if (values.length ()!=5)
{
return false;
}
// bandid, modeid, dxcc, cqz, lognumber
int _dxcc = values.at(2);
//int _dxcc = getDXCCFromId(_qsoId);
if (_dxcc <= 0)
{
//qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: DXCC <= 0: DXCC: " << QString::number(_dxcc) << " - " << QString::number(_qsoId) << QT_ENDL;
return false;
}
int _band = values.at(0);
//int _band = getBandFromId(_qsoId);
if (_band <= 0)
{
//qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: Band <= 0: BAND: " << QString::number(_band) << " - " << QString::number(_qsoId) << QT_ENDL;
return false;
}
int _mode = values.at(1); //int _mode = getModeFromId(_qsoId);
if (_mode <= 0)
{
//qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: Mode <= 0: Mode: " << QString::number(_mode) << " - " << QString::number(_qsoId) << QT_ENDL;
return false;
}
int _log = values.at(4);
//int _log = getLogNumberFromQSOId(_qsoId);
if (_log <= 0)
{
//qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: Log <= 0: Log: " << QString::number(_log) << " - " << QString::number(_qsoId) << QT_ENDL;
return false;
}
// If the band/mode/log is already confirmed: Return true
QSqlQuery query;
// awarddxcc id dxcc band mode confirmed qsoid lognumber
// If the band/mode/log is already confirmed: Return true
// If the band/mode/log is already worked and status worked: Return true
// If the band/mode/log is already worked and status confirmed: Update and Return true
// If not worked: Add and Return true
QString queryString = QString("SELECT id, confirmed, qsoid FROM awarddxcc WHERE band='%1' AND mode='%2' AND dxcc='%3'").arg(_band).arg(_mode).arg(_dxcc);
bool sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: Queryexec-1: " << queryString << QT_ENDL;
queryString.clear();
if (sqlOK)
{
QSqlRecord rec = query.record();
query.next();
//int nameCol = -1;
if (query.isValid())
{
int nameCol = rec.indexOf("id");
int __id = (query.value(nameCol)).toInt();
nameCol = rec.indexOf("confirmed");
QString __confirmed = (query.value(nameCol)).toString();
if (__confirmed == "1")
{ // #1 - If the band/mode/log is already confirmed: Return true
query.finish();
return true;
}
else if (__confirmed == "0")
{
if (!isQSOConfirmed(_qsoId, true, true))
//if (!isQSLReceived((_qsoId)))
{// #2 - If the band/mode/log is already worked and status worked: Return true
query.finish();
return true;
}
else
{ // #3 - If the band/mode/log is already worked and status confirmed: Update and Return true
nameCol = rec.indexOf("qsoid");
//int __qsoid = (query.value(nameCol)).toInt();
queryString = QString("UPDATE awarddxcc SET confirmed = '1', qsoid = '%1' WHERE id = '%2'").arg(_qsoId).arg(__id);
}
}
else
{ // This case should not happen?
query.finish();
return true;
}
query.finish();
// #1 - If the band/mode/log is already confirmed: Return true
// #2 - If the band/mode/log is already worked and status worked: Return true
// #3 - If the band/mode/log is already worked and status confirmed: Update and Return true
// #4 - If not worked: Add and Return true
}
else
{
//#4 - If not worked: Add and Return true
query.finish();
// awarddxcc id dxcc band mode confirmed qsoid lognumber
queryString = QString("INSERT INTO awarddxcc (dxcc, band, mode, confirmed, qsoid, lognumber) values('%1','%2','%3','0', '%4', '%5')").arg(_dxcc).arg(_band).arg(_mode).arg(_qsoId).arg(_log);
}
if (queryString.length()>5)
{
if (query.exec(queryString))
{
//qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: Queryexec-2: " << queryString << QT_ENDL;
query.finish();
return true;
}
else
{
if(query.lastError().nativeErrorCode()!=QString::number(19))
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
query.finish();
return true;
}
bool DataProxy_SQLite::setWAZAwardStatus(const int _qsoId)
{
// If the band/mode/log is already confirmed: Return true
// If the band/mode/log is already worked and status worked: Return true
// If the band/mode/log is already worked and status confirmed: Update and Return true
// If not worked: Add and Return true
//qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: " << QString::number(_qsoId) << QT_ENDL;
if (_qsoId <= 0)
{
return false;
}
QList values;
values.clear();
values << getBandModeDXCCCQZlogIDFromId(_qsoId);
if (values.length ()!=5)
{
return false;
}
// bandid, modeid, dxcc, cqz, lognumber
int _cqz = values.at(3);
//int _cqz = getCQZFromId(_qsoId);
if (_cqz <= 0)
{
return false;
}
//int _band = getBandFromId(_qsoId);
int _band = values.at(0);
if (_band <= 0)
{
return false;
}
//int _mode = getModeFromId(_qsoId);
int _mode = values.at(1);
if (_mode <= 0)
{
return false;
}
//int _log = getLogNumberFromQSOId(_qsoId);
int _log = values.at(4);
if (_log <= 0)
{
return false;
}
// If the band/mode/log is already confirmed: Return true
QSqlQuery query;
// awarddxcc id dxcc band mode confirmed qsoid lognumber
// If the band/mode/log is already confirmed: Return true
// If the band/mode/log is already worked and status worked: Return true
// If the band/mode/log is already worked and status confirmed: Update and Return true
// If not worked: Add and Return true
QString queryString = QString("SELECT id, confirmed, qsoid FROM awardwaz WHERE band='%1' AND mode='%2' AND cqz='%3'").arg(_band).arg(_mode).arg(_cqz);
bool sqlOK = query.exec(queryString);
queryString.clear();
if (sqlOK)
{
QSqlRecord rec = query.record();
query.next();
int nameCol = -1;
if (query.isValid())
{
nameCol = rec.indexOf("id");
int __id = (query.value(nameCol)).toInt();
nameCol = rec.indexOf("confirmed");
QString __confirmed = (query.value(nameCol)).toString();
if (__confirmed == "1")
{ // #1 - If the band/mode/log is already confirmed: Return true
query.finish();
return true;
}
else if (__confirmed == "0")
{
if (!isQSOConfirmed(_qsoId, true, true))
//if (!isQSLReceived((_qsoId)))
{// #2 - If the band/mode/log is already worked and status worked: Return true
query.finish();
return true;
}
else
{ // #3 - If the band/mode/log is already worked and status confirmed: Update and Return true
nameCol = rec.indexOf("qsoid");
//int __qsoid = (query.value(nameCol)).toInt();
queryString = QString("UPDATE awardwaz SET confirmed = '1', qsoid = '%1' WHERE id = '%2'").arg(_qsoId).arg(__id);
}
}
else
{ // This case should not happen?
query.finish();
return true;
}
query.finish();
// #1 - If the band/mode/log is already confirmed: Return true
// #2 - If the band/mode/log is already worked and status worked: Return true
// #3 - If the band/mode/log is already worked and status confirmed: Update and Return true
// #4 - If not worked: Add and Return true
}
else
{
//#4 - If not worked: Add and Return true
query.finish();
// awarddxcc id dxcc band mode confirmed qsoid lognumber
queryString = QString("INSERT INTO awardwaz (cqz, band, mode, confirmed, qsoid, lognumber) values('%1','%2','%3','0', '%4', '%5')").arg(_cqz).arg(_band).arg(_mode).arg(_qsoId).arg(_log);
}
if (queryString.length()>5)
{
if (query.exec(queryString))
{
query.finish();
return true;
}
else
{
if(query.lastError().nativeErrorCode()!=QString::number(19))
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
query.finish();
return true;
}
bool DataProxy_SQLite::addDXCCEntitySubdivision(const QString &_name, const QString &_short, const QString &_pref,
const QString &_group, const int _regId,
const int _dxcc, const int _cq, const int _itu,
const QDate &_startDate, const QDate &_endDate,
const bool _deleted)
{
//qDebug() << "DataProxy_SQLite::addDXCCEntitySubdivision: length: " << _name << QT_ENDL;
// id / name / shortname / prefix / regionalgroup / regionalid / dxcc / cqz / ituz / start_date / end_date / deleted
QString queryString;
QSqlQuery query;
bool sqlOK = false;
//qDebug() << "DataProxy_SQLite::addRegionalAward: Importing: " << _regionalAward.getRegionalAwardRefName(i) << QT_ENDL;
queryString = QString("INSERT INTO primary_subdivisions (name, shortname, prefix, regionalgroup, "
"regionalid, dxcc, cqz, ituz, start_date, end_date, deleted) "
"values ('%1','%2','%3', '%4','%5','%6', '%7','%8', '%9', '%10','%11')")
.arg(_name).arg(_short).arg(_pref).arg(_group).arg(_regId).arg(_dxcc)
.arg(_cq).arg(_itu).arg(util->getDateSQLiteStringFromDate(_startDate))
.arg(util->getDateSQLiteStringFromDate(_endDate)).arg(util->boolToCharToSQLite(_deleted));
sqlOK = query.exec(queryString);
if (sqlOK)
{
//qDebug() << "DataProxy_SQLite::addRegionalAward: " << query.lastQuery() << QT_ENDL;
query.finish();
}
else
{
//qDebug() << "DataProxy_SQLite::addRegionalAward: ERROR " << QT_ENDL;
//qDebug() << "DataProxy_SQLite::addRegionalAward: - query error: " << QString::number(query.lastError().nativeErrorCode()) << QT_ENDL;
//qDebug() << "DataProxy_SQLite::addRegionalAward: LastQuery: " << query.lastQuery() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::addRegionalAward: LastError-data: " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::addRegionalAward: LastError-driver: " << query.lastError().driverText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::addRegionalAward: LastError-n: " << QString::number(query.lastError().nativeErrorCode() ) << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
//qDebug() << "DataProxy_SQLite::addDXCCEntitySubdivision: END" << QT_ENDL;
return true;
}
int DataProxy_SQLite::getNumberOfManagedLogs()
{
//qDebug() << "DataProxy_SQLite::getNumberOfManagedLogs" << QT_ENDL;
QSqlQuery query;
bool sqlOK = query.exec("SELECT COUNT (*) from logs");
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
//return -1;
}
int DataProxy_SQLite::getMaxLogNumber()
{
QSqlQuery query;
QString queryString = QString("SELECT MAX(id) FROM logs");
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
//return -1;
}
QStringList DataProxy_SQLite::getListOfManagedLogs()
{
//This function returns the list of log IDs that are being managed
//qDebug() << "DataProxy_SQLite::getListOfManagedLogs" << QT_ENDL;
QSqlQuery query;
QStringList qs;
qs.clear();
QString queryString = QString("SELECT id FROM logs");
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
while (query.next())
{
if (query.isValid())
{
qs << (query.value(0)).toString();
//qDebug() << "DataProxy_SQLite::getListOfManagedLogs: " << (query.value(0)).toString() << QT_ENDL;
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
qs.clear();
}
query.finish();
return qs;
}
QString DataProxy_SQLite::getStationCallSignFromLog(const int _log)
{
//qDebug() << "DataProxy_SQLite::getStationCallSignFromLog: " << QString::number(_log)<< QT_ENDL;
QSqlQuery query;
QString queryString = QString("SELECT stationcall FROM logs WHERE id='%1'").arg(_log);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::getStationCallSignFromLog: " << (query.value(0)).toString() << QT_ENDL;
QString v = (query.value(0)).toString();
query.finish();
return v;
}
else
{
//qDebug() << "DataProxy_SQLite::getStationCallSignFromLog: Not valid" << QT_ENDL;
query.finish();
return QString();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::getStationCallSignFromLog: query failed" << QT_ENDL;
query.finish();
return QString();
}
//qDebug() << "DataProxy_SQLite::getStationCallSignFromLog: END" << QT_ENDL;
//return QString();
}
QStringList DataProxy_SQLite::getStationCallSignsFromLog(const int _log)
{
//qDebug() << "DataProxy_SQLite::getStationCallSignsFromLog" << QT_ENDL;
QStringList calls = QStringList();
QSqlQuery query;
QString queryString;
bool sqlOK;
if (doesThisLogExist(_log))
{
queryString = QString("SELECT DISTINCT station_callsign FROM log WHERE lognumber='%1'").arg(_log);
}
else
{
queryString = QString("SELECT DISTINCT station_callsign FROM log");
}
sqlOK = query.exec(queryString);
if (sqlOK)
{
while(query.next())
{
if (query.isValid())
{
queryString = (query.value(0)).toString();
if (queryString.length()>2)
{
calls.append(queryString);
}
//qDebug() << "DataProxy_SQLite::getStationCallSignsFromLog: " << queryString << QT_ENDL;
}
else
{
query.finish();
//qDebug() << "DataProxy_SQLite::getStationCallSignsFromLog-END-1 - fail" << QT_ENDL;
return QStringList();
}
}
query.finish();
calls.removeDuplicates();
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
//qDebug() << "DataProxy_SQLite::getStationCallSignsFromLog-END-2 - fail" << QT_ENDL;
return QStringList();
}
calls.sort();
//qDebug() << "DataProxy_SQLite::getStationCallSignsFromLog-END" << QT_ENDL;
return calls;
}
QString DataProxy_SQLite::getOperatorsFromLog(const int _log)
{
//qDebug() << "DataProxy_SQLite::getOperatorsFromLog: " << QString::number(_log)<< QT_ENDL;
QSqlQuery query;
QString queryString = QString("SELECT operators FROM logs WHERE id='%1'").arg(_log);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::getOperatorsFromLog: " << (query.value(0)).toString() << QT_ENDL;
QString v = (query.value(0)).toString();
query.finish();
return v;
}
else
{
//qDebug() << "DataProxy_SQLite::getOperatorsFromLog: Not valid" << QT_ENDL;
query.finish();
return QString();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::getOperatorsFromLog: query failed" << QT_ENDL;
query.finish();
return QString();
}
//qDebug() << "DataProxy_SQLite::getOperatorsFromLog: END" << QT_ENDL;
//return QString();
}
QString DataProxy_SQLite::getCommentsFromLog(const int _log)
{
//qDebug() << "DataProxy_SQLite::getLogDateFromLog: " << QString::number(_log)<< QT_ENDL;
QSqlQuery query;
QString queryString = QString("SELECT comment FROM logs WHERE id='%1'").arg(_log);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::getCommentsFromLog: " << (query.value(0)).toString() << QT_ENDL;
QString v = (query.value(0)).toString();
query.finish();
return v;
}
else
{
//qDebug() << "DataProxy_SQLite::getCommentsFromLog: Not valid" << QT_ENDL;
query.finish();
return QString();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::getLogDateFromLog: query failed" << QT_ENDL;
query.finish();
return QString();
}
//qDebug() << "DataProxy_SQLite::getCommentsFromLog: END" << QT_ENDL;
//return QString();
}
QString DataProxy_SQLite::getLogDateFromLog(const int _log)
{
//qDebug() << "DataProxy_SQLite::getLogDateFromLog: " << QString::number(_log)<< QT_ENDL;
QSqlQuery query;
QString queryString = QString("SELECT logdate FROM logs WHERE id='%1'").arg(_log);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::getLogDateFromLog: " << (query.value(0)).toString() << QT_ENDL;
QString v = (query.value(0)).toString();
query.finish();
return v;
}
else
{
//qDebug() << "DataProxy_SQLite::getLogDateFromLog: Not valid" << QT_ENDL;
query.finish();
return QString();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::getLogDateFromLog: query failed" << QT_ENDL;
query.finish();
return QString();
}
//qDebug() << "DataProxy_SQLite::getLogDateFromLog: END" << QT_ENDL;
//return QString();
}
int DataProxy_SQLite::getLogNumberFromQSOId(const int _qsoId)
{
QSqlQuery query;
QString queryString = QString("SELECT lognumber FROM log WHERE id='%1'").arg(_qsoId);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
}
bool DataProxy_SQLite::fillEmptyDXCCInTheLog()
{
//qDebug() << "DataProxy_SQLite::fillEmptyDXCCInTheLog" << QT_ENDL;
QSqlQuery query;
QSqlQuery query2;
QString queryString = QString("SELECT COUNT (id) FROM log WHERE dxcc IS NULL OR dxcc<'1' OR cont IS NULL");
bool sqlOK = query.exec(queryString);
int qsos = -1;
if (sqlOK)
{
//QSqlDatabase::database().commit();
query.next();
qsos = (query.value(0)).toInt();
query.finish();
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
if (qsos < 1)
{
return true;
}
int step = util->getProgresStepForDialog(qsos);
QProgressDialog progress(QObject::tr("Updating information..."), QObject::tr("Abort updating"), 0, qsos);
progress.setMaximum(qsos);
progress.setWindowModality(Qt::WindowModal);
queryString = QString("SELECT id, call FROM log WHERE dxcc IS NULL OR dxcc<1 OR cont IS NULL");
sqlOK = query.exec(queryString);
if (sqlOK)
{
int nameCol = -1;
QSqlRecord rec = query.record();
QString _call = QString();
QString _id = QString();
QString _dxcc = QString();
QString _aux = QString();
QString _continent = QString();
int j = 0;
while (query.next())
{
if (query.isValid())
{
nameCol = rec.indexOf("id");
_id = (query.value(nameCol)).toString();
nameCol = rec.indexOf("call");
_call = (query.value(nameCol)).toString();
_dxcc = QString::number(getPrefixId(_call));
_continent = getContinentShortNameFromEntity(_dxcc.toInt());
//qDebug() << "DataBase::fillEmptyDXCCInTheLog: DXCC: " << _dxcc << QT_ENDL;
//qDebug() << "DataBase::fillEmptyDXCCInTheLog: Cont: " << _continent << QT_ENDL;
// UPDATE THE ID WITH THE DXCC
queryString = QString("UPDATE log SET dxcc = '%1', cont = '%2' WHERE id = '%3'").arg(_dxcc).arg(_continent).arg(_id);
sqlOK = query2.exec(queryString);
if (!sqlOK)
{
emit queryError(Q_FUNC_INFO, query2.lastError().databaseText(), query2.lastError().nativeErrorCode(), query2.lastQuery());
query2.finish();
return false;
}
query2.finish();
if (( (j % step )== 0) )
{ // To update the speed I will only show the progress once each X QSOs
_aux = QObject::tr("Updating DXCC and Continent information...") + "\n" + QObject::tr("QSO: ") + QString::number(j) + "/" + QString::number(qsos);
//_aux = "Updating ...";
progress.setLabelText(_aux);
progress.setValue(j);
}
if ( progress.wasCanceled() )
{
//qDebug() << "DataBase::fillEmptyDXCCInTheLog: progress canceled" << QT_ENDL;
query.finish();
return true;
}
j++;
}
}
progress.setValue(qsos);
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(tr("KLog DXCC"));
msgBox.setText(tr("All QSOs have been updated with a DXCC and the Continent.") );
msgBox.exec();
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
query.finish();
return true;
}
int DataProxy_SQLite::getHowManyQSOInLog(const int _log)
{
QString queryString = QString();
QSqlQuery query = QSqlQuery();
if (_log < 0)
{
queryString = QString("SELECT count(id) FROM log");
}
else
{
queryString = QString("SELECT count(id) FROM log WHERE lognumber='%1'").arg(_log);
}
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return 0;
}
}
int DataProxy_SQLite::getHowManyConfirmedQSLInLog(const int _log)
{
if (!doesThisLogExist(_log) && (_log>0))
{
return 0;
}
QString queryString = QString();
QSqlQuery query;
if (_log < 0)
{
queryString = QString("SELECT count(id) FROM log WHERE (qsl_rcvd='Y' OR lotw_qsl_rcvd='Y')");
}
else
{
queryString = QString("SELECT count(id) FROM log WHERE (qsl_rcvd='Y' OR lotw_qsl_rcvd='Y') AND lognumber='%1'").arg(_log);
}
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return 0;
}
}
int DataProxy_SQLite::getHowManyQSLSentInLog(const int _log)
{
if (!doesThisLogExist(_log) && (_log>0))
{
return 0;
}
QString queryString = QString();
QSqlQuery query;
if (_log < 0)
{
queryString = QString("SELECT count(id) FROM log WHERE qsl_sent='Y'");
}
else
{
queryString = QString("SELECT count(id) FROM log WHERE qsl_sent='Y' AND lognumber='%1'").arg(_log);
}
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return 0;
}
}
int DataProxy_SQLite::getQSOsWithContinent(const QString &_cont, const int _logNumber)
{
//qDebug() << "DataProxy_SQLite::getQSOsWithContinent: " << _cont << QT_ENDL;
QSqlQuery query;
QString queryString;
bool sqlOK;
if (_logNumber < 0)
{
queryString = QString("SELECT COUNT (DISTINCT id) FROM log where cont LIKE '%1'").arg(_cont);
}
else
{
queryString = QString("SELECT COUNT (DISTINCT id) FROM log where lognumber='%1' AND cont LIKE '%2'").arg(_logNumber).arg(_cont);
}
sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::getQSOsWithContinent: queryString: " << queryString << QT_ENDL;
if (sqlOK)
{
query.next();
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::getQSOsWithContinent: " << QString::number((query.value(0)).toInt()) << QT_ENDL;
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
//qDebug() << "DataProxy_SQLite::getQSOsWithContinent: 0" << QT_ENDL;
query.finish();
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::getQSOsWithContinent: Query error" << QT_ENDL;
query.finish();
return 0;
}
}
int DataProxy_SQLite::getQSOsInBand(const QString &_band, const int _log)
{
if (!doesThisLogExist(_log) && (_log>0))
{
return 0;
}
int bandId = getIdFromBandName(_band);
if ( bandId < 0)
{
return 0;
}
QString queryString = QString();
QSqlQuery query;
if (_log < 0)
{
queryString = QString("SELECT count(id) FROM log WHERE bandid='%1'").arg(bandId);
}
else
{
queryString = QString("SELECT count(id) FROM log WHERE bandid='%1' AND lognumber='%2'").arg(bandId).arg(_log);
}
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return 0;
}
}
int DataProxy_SQLite::getQSOsInMode(const QString &_mode, const int _log)
{
if (!doesThisLogExist(_log) && (_log>0))
{
return 0;
}
int modeId = getIdFromModeName(_mode);
if ( modeId < 0)
{
return 0;
}
QString queryString = QString();
QSqlQuery query;
if (_log < 0)
{
queryString = QString("SELECT count(id) FROM log WHERE modeid='%1'").arg(modeId);
}
else
{
queryString = QString("SELECT count(id) FROM log WHERE modeid='%1' AND lognumber='%2'").arg(modeId).arg(_log);
}
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return 0;
}
}
QList> DataProxy_SQLite::getTop10QSOPerDXCC(const int _log)
{
//qDebug() << Q_FUNC_INFO << " : " << QString::number(_log) << QT_ENDL;
QList> result;
result.clear();
QSqlQuery query;
QString queryString;
if (_log <0)
{
queryString = "SELECT log.dxcc, COUNT(log.dxcc) FROM log GROUP BY log.dxcc ORDER BY COUNT(log.dxcc) DESC LIMIT 10";
}
else
{
queryString = QString("select log.dxcc, count(log.dxcc) from log WHERE log.lognumber = '%1' group by log.dxcc ORDER BY count(log.dxcc) DESC limit 10").arg(_log);
}
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
QList temp;
while (query.next())
{
if (query.isValid())
{
temp.clear();
temp.append(query.value(0).toInt());
temp.append(query.value(1).toInt());
result.append(temp);
//_id = (query.value(nameCol)).toString();
}
}
return result;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return result;
}
//qDebug() << Q_FUNC_INFO << " - END" << QT_ENDL;
//return result;
}
bool DataProxy_SQLite::addNewLog (const QStringList _qs)
{
//qDebug() << "DataProxy_SQLite::addNewLog: " << _qs.at(2) << "/" << _qs.at(5) << "/" << _qs.at(6) << QT_ENDL;
//qDebug() << "DataProxy_SQLite::addNewLog: Size: " << QString::number(_qs.size()) << QT_ENDL;
// newLogq << dateString << stationCallsign << operators << comment << QString::number(selectedLog) << _qs.at(4) ; (last field is 1 or 0 editing)
if (_qs.size()!=6)
{
//qDebug() << "DataProxy_SQLite::addNewLog: != 6" << QT_ENDL;
return false;
}
//qDebug() << "DataProxy_SQLite::addNewLog: Has the appropriate length" << QT_ENDL;
QString aux = QString();
QString _dateString = _qs.at(0);
QString _stationCallsign = _qs.at(1);
QString _operators = _qs.at(2);
QString _comment = _qs.at(3);
QString id = _qs.at(4);
QString editing = _qs.at(5);
QString queryString;
QSqlQuery query;
bool sqlOK;
if (editing == "1")
{ // We are editing
//qDebug() << "DataProxy_SQLite::addNewLog: We are editing!" << QT_ENDL;
//queryString = QString("UPDATE logs SET logdate = '%1', stationcall = '%2', operators = '%3', comment = '%4', logtype = '%5', logtypen = '%6' WHERE id = '%7'").arg(_dateString).arg(_stationCallsign).arg(_operators).arg(_comment).arg(_typeContest).arg(_typeContestN).arg(id);
queryString = QString("UPDATE logs SET logdate = '%1', stationcall = '%2', operators = '%3', comment = '%4' WHERE id = '%5'").arg(_dateString).arg(_stationCallsign).arg(_operators).arg(_comment).arg(id);
sqlOK = query.exec(queryString);
if (sqlOK)
{
//qDebug() << "DataProxy_SQLite::addNewLog: Editing OK!" << QT_ENDL;
query.finish();
return true;
}
else
{
//qDebug() << "DataProxy_SQLite::addNewLog: Editing NOK!" << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
//return false;
}
//qDebug() << "DataProxy_SQLite::addNewLog: We are adding a new log" << QT_ENDL;
// First we check if the log is already there
queryString = QString("SELECT id FROM logs WHERE logdate='%1' AND stationcall='%2' AND operators = '%3' AND comment = '%4'").arg(_dateString).arg(_stationCallsign).arg(_operators).arg(_comment);
//"logs"
//"id, logdate, stationcall, comment, logtype"
//qDebug() << "DataProxy_SQLite::addNewLog query1: " << queryString << QT_ENDL;
sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::addNewLog query error: " << queryString << QT_ENDL;
// It seems that the log is already existing!
return false;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
//Now we add the new log
queryString = QString("INSERT INTO logs (logdate, stationcall, operators, comment) values('%1','%2','%3','%4')").arg(_dateString).arg(_stationCallsign).arg(_operators).arg(_comment);
//qDebug() << "DataProxy_SQLite::addNewLog query1: " << queryString << QT_ENDL;
sqlOK = query.exec(queryString);
if (sqlOK)
{
query.finish();
return true;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
//return false;
}
bool DataProxy_SQLite::doesThisLogExist(const int _log)
{
//qDebug() << "DataProxy_SQLite::doesThisLogExist: " << QString::number(_log) << QT_ENDL;
//qDebug() << "DataProxy_SQLite::doesThisLogExist - Name:" << db->getDBName() << QT_ENDL;
QSqlQuery query;
QString queryString = QString("SELECT id FROM logs WHERE id='%1'").arg(_log);
bool sqlOK = query.exec(queryString);
//qDebug() << "DataProxy_SQLite::doesThisLogExist: query: " << query.lastQuery() << QT_ENDL;
if (sqlOK)
{
if (query.next())
{
if (query.isValid())
{
query.finish();
//qDebug() << "DataProxy_SQLite::doesThisLogExist: END TRUE" << QT_ENDL;
return true;
}
else
{
query.finish();
//qDebug() << "DataProxy_SQLite::doesThisLogExist: END FALSE 1" << QT_ENDL;
return false;
}
}
else
{
query.finish();
//qDebug() << "DataProxy_SQLite::doesThisLogExist: END FALSE 2" << QT_ENDL;
return false;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
//qDebug() << "DataProxy_SQLite::doesThisLogExist: END FALSE 3" << QT_ENDL;
return false;
}
//qDebug() << "DataProxy_SQLite::doesThisLogExist: END FALSE 4" << QT_ENDL;
//return false;
}
int DataProxy_SQLite::getContinentIdFromContinentShortName(const QString &_n)
{
if (_n.length()!=2)
{
return -3;
}
QSqlQuery query;
QString queryString = QString("SELECT id FROM continent WHERE shortname=='%1'").arg(_n);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -2;
}
}
QString DataProxy_SQLite::getContinentShortNameFromEntity(const int _n)
{
QSqlQuery query;
QString queryString= QString("SELECT continent FROM entity WHERE dxcc='%1'").arg(_n);
//QString queryString= QString("SELECT continent.shortname FROM entity JOIN continent ON entity.continent=continent.shortname WHERE dxcc='%1'").arg(_n);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
queryString = (query.value(0)).toString();
query.finish();
return queryString;
}
else
{
query.finish();
return QString();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
}
int DataProxy_SQLite::getContinentIdFromEntity(const int _n)
{
QSqlQuery query;
QString queryString = QString("SELECT continent.id FROM entity JOIN continent ON entity.continent=continent.shortname WHERE dxcc='%1'").arg(_n);
bool sqlOK = query.exec(queryString);
//aux = QString("SELECT continent.id FROM entity JOIN continent ON entity.continent=continent.shortname WHERE (mainprefix NOT LIKE '*%') AND dxcc='%1'").arg(_n);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -2;
}
}
QStringList DataProxy_SQLite::getContinentShortNames()
{
QSqlQuery query;
QStringList continents;
continents.clear();
QString queryString = QString("SELECT shortname FROM continent");
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
while (query.next())
{
if (query.isValid())
{
continents << query.value(0).toString();
}
}
query.finish();
continents.sort();
return continents;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QStringList();
}
//return QStringList();
}
bool DataProxy_SQLite::isValidContinentShortName(const QString &_n)
{
QString queryString = QString("SELECT id FROM continent WHERE shortname ='%1'").arg(_n);
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
if (query.next())
{
if (query.isValid())
{
query.finish();
return true;
}
else
{
query.finish();
return false;
}
}
else
{
query.finish();
return false;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
}
bool DataProxy_SQLite::isValidDXCC(const int _e)
{
QString queryString = QString("SELECT id FROM entity WHERE dxcc ='%1'").arg(_e);
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
if (query.next())
{
if (query.isValid())
{
if (query.value(0).toInt()==1)
query.finish();
return true;
}
else
{
query.finish();
return false;
}
}
else
{
query.finish();
return false;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
}
QStringList DataProxy_SQLite::filterValidFields(const QStringList &_fields)
{
//qDebug() << Q_FUNC_INFO << ": Length: " << QString::number(_fields.length());
QStringList validFields;
validFields.clear();
validFields << getFields();
QString aux;
//foreach(aux, validFields)
//{
// //qDebug() << Q_FUNC_INFO << ": validFields: " << aux;
//}
foreach(aux, _fields)
{
//qDebug() << Q_FUNC_INFO << ": _fields: " << aux;
}
QStringList returningFields;
returningFields.clear();
QString field;
foreach (field, _fields)
{
//qDebug() << Q_FUNC_INFO << ": Field:-1: " << field;
field = field.trimmed();
if (field.endsWith(';'))
{
field.chop(1);
}
//qDebug() << Q_FUNC_INFO << ": Field:-2: " << field;
if (validFields.contains(field))
{
returningFields << field;
}
}
if (returningFields.isEmpty())
{
returningFields << util->getDefaultLogFields();
}
return returningFields;
}
int DataProxy_SQLite::getITUzFromPrefix(const QString &_p)
{
QSqlQuery query;
QString queryString = QString("SELECT ituz FROM prefixesofentity WHERE prefix LIKE '%1'").arg(_p);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -2;
}
}
int DataProxy_SQLite::getCQzFromPrefix(const QString &_p)
{
QSqlQuery query;
QString queryString = QString("SELECT cqz FROM prefixesofentity WHERE prefix LIKE '%1'").arg(_p);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -2;
}
}
int DataProxy_SQLite::getCQzFromEntity(const int _n)
{
QSqlQuery query;
QString queryString = QString("SELECT cqz FROM entity WHERE dxcc='%1'").arg(_n);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -2;
}
}
int DataProxy_SQLite::getITUzFromEntity(const int _n)
{
QSqlQuery query;
QString queryString = QString("SELECT ituz FROM entity WHERE dxcc='%1'").arg(_n);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -2;
}
}
QString DataProxy_SQLite::getEntityNameFromId(const int _n)
{
//qDebug() << "DataProxy_SQLite::getEntityNameFromId: " << QString::number(_n) << QT_ENDL;
QSqlQuery query;
QString queryString = QString("SELECT name FROM entity WHERE dxcc='%1'").arg(_n);
QString motherEntName = QString();
bool sqlOK;
if (_n > 1000)
{
QString aux = (QString::number(_n)).right(3);
QString queryString2 = QString("SELECT name FROM entity WHERE dxcc='%1'").arg(aux);
sqlOK = query.exec(queryString2);
if (sqlOK)
{
if (query.next())
{
if (query.isValid())
{
motherEntName = (query.value(0)).toString();
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
}
query.finish();
sqlOK = query.exec(queryString);
if (sqlOK)
{
if (query.next())
{
if (query.isValid())
{
if (_n>1000)
{
motherEntName = (query.value(0)).toString() + " (" + motherEntName + ")";
}
else
{
motherEntName = (query.value(0)).toString();
}
query.finish();
return motherEntName;
}
else
{
query.finish();
return QString();
}
}
else
{
query.finish();
return QString();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
//return QString();
}
int DataProxy_SQLite::getEntityIdFromName(const QString &_e)
{
//qDebug() << "DataProxy_SQLite::getEntityIdFromName:" << _e << QT_ENDL;
int id = -1;
QString queryString;
QSqlQuery query;
//queryString = QString("SELECT mainprefix FROM entity WHERE (mainprefix NOT LIKE '*%') AND dxcc='%1'").arg(_entityN);
queryString = QString("SELECT dxcc FROM entity WHERE name='%1'").arg(_e);
//queryString = "SELECT prefix FROM prefixesofentity WHERE dxcc=='" + QString::number(i) +"'";
bool sqlOK = query.exec(queryString);
if (!sqlOK)
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return id;
}
else
{
query.next();
if (query.isValid())
{
id = (query.value(0)).toInt();
query.finish();
return id;
}
else
{
query.finish();
return -1;
}
}
}
QStringList DataProxy_SQLite::getEntiNameISOAndPrefixFromId(const int _dxcc)
{
//qDebug() << Q_FUNC_INFO << ": " << QString::number(_dxcc);
if (_dxcc <= 0 )
{
return QStringList();
}
bool sqlOK;
QString queryString;
QSqlQuery query;
QString motherEntName = QString();
if (_dxcc > 1000)
{
QString aux = (QString::number(_dxcc)).right(3);
QString queryString2 = QString("SELECT name FROM entity WHERE dxcc='%1'").arg(aux);
sqlOK = query.exec(queryString2);
if (sqlOK)
{
if (query.next())
{
if (query.isValid())
{
motherEntName = (query.value(0)).toString();
if (motherEntName.length ()<1)
{
return QStringList();
}
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish ();
return QStringList();
}
}
query.finish ();
QStringList result;
result.clear();
queryString = QString("SELECT mainprefix, name, isoname FROM entity WHERE dxcc='%1'").arg(_dxcc);
sqlOK = query.exec(queryString);
if (!sqlOK)
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QStringList();
}
else
{
query.next();
if (query.isValid())
{
//queryString = (query.value(0)).toString();
QString prefix = (query.value(0)).toString();
QString name = (query.value(1)).toString();
QString isoName = (query.value(2)).toString();
query.finish();
if (prefix.length ()<1)
{
return QStringList();
}
if (name.length ()<1)
{
return QStringList();
}
if ((_dxcc>1000) && (motherEntName.length ()>2))
{
name = name + "(" + motherEntName + ")";
}
if (isoName.length ()<2)
{
return QStringList();
}
result << prefix << name << isoName;
return result;
}
else
{
query.finish();
return QStringList();
}
}
}
QString DataProxy_SQLite::getEntityMainPrefix(const int _entityN)
{
//qDebug() << "DataProxy_SQLite::getEntityMainPrefix:" << QString::number(_entityN) << QT_ENDL;
if (_entityN <= 0 )
{
return QString();
}
QString queryString;
QSqlQuery query;
queryString = QString("SELECT mainprefix FROM entity WHERE dxcc='%1'").arg(_entityN);
bool sqlOK = query.exec(queryString);
if (!sqlOK)
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
else
{
query.next();
if (query.isValid())
{
queryString = (query.value(0)).toString();
query.finish();
return queryString;
}
else
{
query.finish();
return QString();
}
}
//return QString();
}
int DataProxy_SQLite::getEntityIdFromMainPrefix(const QString &_e)
{
//qDebug() << "DataProxy_SQLite::getEntityIdFromMainPrefix:" << _e << QT_ENDL;
int id = -1;
QString queryString;
QSqlQuery query;
queryString = QString("SELECT dxcc FROM entity WHERE mainprefix='%1'").arg(_e);
bool sqlOK = query.exec(queryString);
if (!sqlOK)
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return id;
}
else
{
query.next();
if (query.isValid())
{
id = (query.value(0)).toInt();
query.finish();
return id;
}
else
{
query.finish();
return -1;
}
}
}
int DataProxy_SQLite::getDXCCFromPrefix(const QString &_p)
{
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix - " << Q_FUNC_INFO << "-" << _p << "-" << QT_ENDL;
QSqlQuery query;
QString queryString = QString("SELECT dxcc FROM prefixesofentity WHERE prefix='%1'").arg(_p);
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: query OK: query: " << queryString << QT_ENDL;
if (query.next())
{
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: return 0: " << QString::number(v) << QT_ENDL;
return v;
}
else
{
query.finish();
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: return -1: " << QT_ENDL;
return -1;
}
}
else
{
query.finish();
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: return -2: " << QT_ENDL;
return -2;
}
}
else
{
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: query NOK: query: " << queryString << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: return -3: " << QT_ENDL;
return -3;
}
//return -4;
}
bool DataProxy_SQLite::isNewCQz(int _c)
{
QSqlQuery query;
QString queryString = QString("SELECT id FROM log WHERE cqz='%1'").arg(_c);
//queryString = "SELECT id FROM log WHERE cqz=='" + QString::number(_cqz) +"'";
bool sqlOK = query.exec(queryString);
if (!sqlOK)
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
else
{
query.next();
return query.isValid();
}
}
bool DataProxy_SQLite::isNewEntity(int _e)
{
if (_e <= 0)
{
return false;
}
//QString queryString;
QSqlQuery query;
QString queryString = QString("SELECT id FROM log WHERE dxcc='%1'").arg(_e);
//queryString = "SELECT id FROM log WHERE dxcc=='" + QString::number(_entityN) +"'";
bool sqlOK = query.exec(queryString);
if (!sqlOK)
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
else
{
query.next();
if (query.isValid())
{
query.finish();
return true;
}
else
{
query.finish();
return false;
}
}
//return false;
}
double DataProxy_SQLite::getLongitudeFromEntity(const int _e)
{
QString queryString = QString("SELECT longitude FROM entity WHERE dxcc='%1'").arg(_e);
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (!sqlOK)
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return 0.0;
}
else
{
query.next();
if ( !(query.isValid()) )
{
query.finish();
return 0.0;
}
else
{ double v = (query.value(0)).toDouble();
query.finish();
return v;
}
}
}
double DataProxy_SQLite::getLatitudeFromEntity(const int _e)
{
QString queryString = QString("SELECT latitude FROM entity WHERE dxcc='%1'").arg(_e);
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (!sqlOK)
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return 0.0;
}
else
{
query.next();
if ( !(query.isValid()) )
{
query.finish();
return 0.0;
}
else
{
double v = (query.value(0)).toDouble();
query.finish();
return v;
}
}
}
QString DataProxy_SQLite::getEntityPrefixes(const int _enti)
{
if (_enti<=0)
{
return QString();
}
QString result;
result = QString();
QString queryString;
QSqlQuery query;
int i = _enti;
queryString = "SELECT prefix FROM prefixesofentity WHERE dxcc=='" + QString::number(i) +"'";
bool sqlOK = query.exec(queryString);
if (!sqlOK)
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return QString();
}
else
{
while ( (query.next())) {
if (query.isValid())
{
result = result + ", " + (query.value(0)).toString();
}
}
if (result.length() < 1)
{
return result;
}
else
{
result = result.remove(0,2);
query.finish();
return result;
}
}
}
QStringList DataProxy_SQLite::getEntitiesNames()
{
//qDebug() << "DataProxy_SQLite::getEntitiesNames" << QT_ENDL;
QString aux = QString();
QStringList qs;
qs.clear();
QString queryString = QString("SELECT mainprefix, name, dxcc FROM entity");
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
while ( (query.next())) {
if (query.isValid())
{
if (query.value(2).toInt()<1000)
{
aux.clear();
aux = (query.value(0)).toString() + "-" + (query.value(1)).toString()+" ("+(query.value(2)).toString()+")";
//result = result + ", " + (query.value(0)).toString();
qs << aux;
}
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
query.finish();
qs.sort();
return qs;
}
QStringList DataProxy_SQLite::getEntitiesIds()
{
QString aux = QString();
QStringList qs;
qs.clear();
QString queryString = QString("SELECT dxcc FROM entity");
QSqlQuery query;
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
while ( (query.next())) {
if (query.isValid())
{
if (query.value(0).toInt()>0)
{
aux.clear();
aux = (query.value(0)).toString();
qs << aux;
}
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
query.finish();
qs.sort();
return qs;
}
int DataProxy_SQLite::getHowManyEntities()
{
QSqlQuery query;
QString queryString = QString("SELECT count(id) FROM entity");
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
query.finish();
return v;
}
else
{
query.finish();
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return 0;
}
}
int DataProxy_SQLite::getMaxEntityID(bool limit)
{
//SELECT MAX (dxcc) FROM entity WHERE dxcc<1000
QSqlQuery query;
QString queryString;
if (limit)
{
queryString = QString("SELECT MAX (dxcc) FROM entity WHERE dxcc<1000");
}
else
{
queryString = QString("SELECT MAX (dxcc) FROM entity");
}
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -1;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
}
bool DataProxy_SQLite::updateISONames()
{
//qDebug() << "DataProxy_SQLite::updateISONames" << QT_ENDL;
return db->updateTheEntityTableISONames();
}
QString DataProxy_SQLite::getISOName(const int _n)
{
//qDebug() << "DataProxy_SQLite::getISONames: " << QString::number(_n) << QT_ENDL;
if (_n <= 0 )
{
//qDebug() << "DataProxy_SQLite::getISONames: NOT KNOWN - UN" << QT_ENDL;
return "un"; // When no flag is known, we return the UN flag
}
int n = _n;
if (_n<1000)
{
n = _n;
}
else if (_n>=2000)
{
n = _n - 2000;
}
else
{
n = _n - 1000;
}
QString queryString, aux;
QSqlQuery query;
aux.clear();
queryString = QString("SELECT isoname FROM entity WHERE dxcc='%1'").arg(n);
bool sqlOK = query.exec(queryString);
if (!sqlOK)
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "DataProxy_SQLite::getISOName: Query error - UN" << QT_ENDL;
query.finish();
return "un"; // When no flag is known, we return the UN flag
}
else
{
query.next();
if (query.isValid()){
//qDebug() << "DataProxy_SQLite::getISOName: " << "N: " << QString::number(_n) << "- ISO Name: " << (query.value(0)).toString() << QT_ENDL;
aux = (query.value(0)).toString();
query.finish();
if (aux.length()>1)
{
return aux;
}
else
{
return "un"; // When no flag is known, we return the UN flag
}
}
else
{
//qDebug() << "DataProxy_SQLite::getISOName: NO ISO Name: " << QT_ENDL;
query.finish();
return "un"; // When no flag is known, we return the UN flag
}
}
}
int DataProxy_SQLite::getPrefixId(const QString &_qrz)
{
//qDebug() << "DataProxy_SQLite::getPrefixId: -" << _qrz <<"-" << QT_ENDL;
//TODO: Instead of going from long to short, identify prefixes from the begining:
// character(may be number) + number
if (_qrz.length() < 1)
{
return -1;
}
int entityID = 0;
QString aux = changeSlashAndFindPrefix((_qrz).toUpper());
while ((entityID <= 0) && (aux.length()>=1) )
{
entityID = getDXCCFromPrefix(aux);
//qDebug() << "DataProxy_SQLite::getPrefixId: in the while" << aux << " = " << QString::number(entityID) << QT_ENDL;
if (entityID<=0)
{
aux.chop(1);
}
}
//qDebug() << "DataProxy_SQLite::getPrefixId: " << _qrz << QString::number(entityID) << QT_ENDL;
return entityID;
}
QString DataProxy_SQLite::changeSlashAndFindPrefix(const QString &_qrz)
{
//qDebug() << "DataProxy_SQLite::changeSlashAndFindPrefix: -" << _qrz <<"-" << QT_ENDL;
int iaux1, iaux2;
QString aux = _qrz.toUpper();
if ((aux).count('\\')) // Replaces \ by / to ease operation.
{
aux.replace(QChar('\\'), QChar('/'));
}
else
{
return aux;
}
if (aux.count('/')) // / found! Checking different options
{
if (aux.endsWith("/") )
{ // We look for calls ending in slash "/" or "\"
aux.remove(aux.length()-1,1);
}
iaux1 = aux.indexOf('/');
//qDebug() << "DataProxy_SQLite::changeSlashAndFindPrefix: Slash found at: " << QString::number(iaux1) << QT_ENDL;
iaux2 = (aux.length())- iaux1; // iaux2 is the length of the second part
if (iaux2 < 0){
iaux2 = -iaux2;
}
if ( iaux1 < iaux2 ) { //Like in F/EA0K, we can simply take the first part as the prefix
aux = aux.left(iaux1);
}
else
{
aux = aux.right(iaux2 -1);
}
}
return aux;
}
void DataProxy_SQLite::slotCaptureDebugLogs(const QString &_func, const QString &_msg, const DebugLogLevel _level)
{
emit debugLog(_func, _msg, _level);
}
QString DataProxy_SQLite::getADIFQSO(const int _qsoId)
{
QString ADIFqso;
ADIFqso.clear();
//qDebug() << "DataProxy_SQLite::getADIFQSO: " << QString::number(_qsoId) << QT_ENDL;
int nameCol;
QString aux;
bool propsat = false; // Reset the QSO in case it is a Satellite QSO
QSqlQuery query;
QString queryString = QString("SELECT * FROM log WHERE id='%1'").arg(_qsoId);
bool sqlOk = query.exec(queryString);
if (sqlOk)
{
if (query.next())
{
if (query.isValid())
{
//qDebug() << "DataProxy_SQLite::getADIFQSO: Query OK: " << query.lastQuery() << QT_ENDL;
}
else
{
//qDebug() << "DataProxy_SQLite::getADIFQSO: Query isValid FAILED: " << query.lastQuery() << QT_ENDL;
query.finish();
return QString();
}
}
else
{
//qDebug() << "DataProxy_SQLite::getADIFQSO: Query NEXT FAILED: " << query.lastQuery() << QT_ENDL;
query.finish();
return QString();
}
}
else
{
//qDebug() << "DataProxy_SQLite::getADIFQSO: Query FAILED: " << query.lastQuery() << QT_ENDL;
query.finish();
return QString();
}
QSqlRecord rec = query.record();
nameCol = rec.indexOf("call");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
//qDebug() << "DataProxy_SQLite::getADIFQSO: " << QString::number(nameCol) << "/" << aux1 << QT_ENDL;
if (util->isValidCall(aux))
{
ADIFqso.append("" + aux + " ");
}
else
{
if (showInvalidCallMessage(aux))
{
ADIFqso.append("" + aux + " ");
}
}
}
nameCol = rec.indexOf("qso_date");
QDateTime tDateTime;
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
tDateTime = util->getDateTimeFromSQLiteString(aux);
if (tDateTime.isValid())
{
aux = util->getADIFDateFromQDateTime(tDateTime);
ADIFqso.append("" + aux + " ");
aux = util->getADIFTimeFromQDateTime(tDateTime);
//aux.chop(2);
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("bandid");
QString bandst = QString();
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
aux = util->checkAndFixASCIIinADIF(aux);
aux = getNameFromBandId(aux.toInt());
if (getIdFromBandName(aux)>=0)
{
bandst = aux;
}
}
nameCol = rec.indexOf("freq");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
aux = util->checkAndFixASCIIinADIF(aux);
double freqTX = aux.toDouble();
if (freqTX > 0.0)
{
//TODO: Check if the Band is correctly defined. BAND Wins and freq is lost if not correct
if (getBandIdFromFreq(freqTX) != getIdFromBandName(bandst))
{
bandst = getBandNameFromFreq(freqTX);
}
ADIFqso.append("" + aux + " ");
}
if (getIdFromBandName(bandst)>0)
{
ADIFqso.append("" + bandst + " ");
}
}
// Now the BAND RX
nameCol = rec.indexOf("band_rx");
QString bandrxst = QString();
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
aux = util->checkAndFixASCIIinADIF(aux);
aux = getNameFromBandId(aux.toInt());
if (getIdFromBandName(aux)>=0)
{
bandrxst = aux;
}
}
nameCol = rec.indexOf("freq_rx");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
aux = util->checkAndFixASCIIinADIF(aux);
double freqRX = aux.toDouble();
if (freqRX > 0.0)
{
//TODO: Check if the Band is correctly defined. BAND Wins and freq is lost if not correct
if (getBandIdFromFreq(freqRX) != getIdFromBandName(bandrxst))
{
bandrxst = getBandNameFromFreq(freqRX);
}
ADIFqso.append("" + aux + " ");
}
if (getIdFromBandName(bandrxst)>0)
{
ADIFqso.append("" + bandrxst + " ");
}
// END of Band RX
}
nameCol = rec.indexOf("modeid");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
aux = util->checkAndFixASCIIinADIF(aux);
// get SubModeId to check if it is the same or not from modeid
QString aux2 = getSubModeFromId(aux.toInt());
//aux = db->getModeNameFromID2(aux.toInt());
aux = getNameFromSubMode(aux2);
if ((aux.length()>1) && (getIdFromModeName(aux)>=0))
{
ADIFqso.append("" + aux + " ");
}
if ((aux != aux2) && (aux.length()>1) && (getSubModeIdFromSubMode(aux2)>=0) )
{
ADIFqso.append("" + aux2 + " ");
}
}
nameCol = rec.indexOf("prop_mode");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>1)
{
ADIFqso.append("" + aux + " ");
if (aux == "SAT")
{
propsat = true;
}
}
//qDebug() << "DataProxy_SQLite::getADIFQSO: PROP_MODE" << QT_ENDL;
}
nameCol = rec.indexOf("sat_name");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
if (!propsat)
{
ADIFqso.append("SAT ");
propsat = false;
}
}
//qDebug() << "DataProxy_SQLite::getADIFQSO: SAT_NAME" << QT_ENDL;
}
nameCol = rec.indexOf("gridsquare");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_gridsquare");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("station_callsign");
if ((nameCol>=0) )
{
aux = (query.value(nameCol)).toString();
//qDebug() << "DataProxy_SQLite::getADIFQSO: StationCallSign: " << aux << QT_ENDL;
if ((util->isValidCall(aux)))
{ // User selected one station callsign from the log
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("qso_date_off");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
aux = util->checkAndFixASCIIinADIF(aux);
tDateTime = util->getDateTimeFromSQLiteString(aux);
if (tDateTime.isValid())
{
aux = util->getADIFDateFromQDateTime(tDateTime);
ADIFqso.append("" + aux + " ");
aux = util->getADIFTimeFromQDateTime(tDateTime);
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("srx");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("srx_string");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("stx");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("stx_string");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
//qDebug() << "DataProxy_SQLite::getADIFQSO - 100" << QT_ENDL;
nameCol = rec.indexOf("cqz");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ( ((aux.length())>0) && (0 < aux.toInt()) && (aux.toInt() < CQZones+1) )
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("ituz");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ( ((aux.length())>0) && (0 < aux.toInt()) && (aux.toInt() < ITUZones+1) )
{
ADIFqso.append("" + aux + " ");
}
//qDebug() << "DataProxy_SQLite::getADIFQSO: DXCC - Now..." << QT_ENDL;
}
nameCol = rec.indexOf("dxcc");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
//qDebug() << "DataProxy_SQLite::getADIFQSO: DXCC " << aux << QT_ENDL;
}
//qDebug() << "DataProxy_SQLite::getADIFQSO: DXCC - Exported!" << QT_ENDL;
}
nameCol = rec.indexOf("address");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("age");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("cnty");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("comment");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
//qDebug() << "DataProxy_SQLite::getADIFQSO - 200" << QT_ENDL;
}
nameCol = rec.indexOf("a_index");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("ant_az");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("ant_el");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("ant_path");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("arrl_sect");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("checkcontest");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
//qDebug() << "DataProxy_SQLite::getADIFQSO - 30" << QT_ENDL;
nameCol = rec.indexOf("class");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("cont");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("contacted_op");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if (util->isValidCall(aux))
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("contest_id");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("points");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("multiplier");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
//qDebug() << "DataProxy_SQLite::getADIFQSO - 40" << QT_ENDL;
}
nameCol = rec.indexOf("transmiterid");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("country");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("credit_submitted");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("credit_granted");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("distance");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("darc_dok");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("eq_call");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if (util->isValidCall(aux))
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("email");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
if (aux.contains("@") && (aux.contains(".")))
{
ADIFqso.append("" + aux + " ");
}
}
}
nameCol = rec.indexOf("eqsl_qslrdate");
QDate date;
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
date = util->getDateFromSQliteString(aux);
if (date.isValid())
{
aux = util->getADIFDateFromQDate(date);
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("eqsl_qslsdate");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
date = util->getDateFromSQliteString(aux);
if (date.isValid())
{
aux = util->getADIFDateFromQDate(date);
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("eqsl_qsl_rcvd");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ( ((aux.length())==1) && (aux!="N") )
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("eqsl_qsl_sent");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ( ((aux.length())==1) && (aux!="N") )
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("fists");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("fists_cc");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("force_init");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("guest_op");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("hrdlog_qso_upload_date");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
date = util->getDateFromSQliteString(aux);
if (date.isValid())
{
aux = util->getADIFDateFromQDate(date);
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("hrdlog_qso_upload_status");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ( ((aux.length())==1) && ((aux!="Y") || (aux!="N") || (aux!="M")) )
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_antenna");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_dxcc");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_fists");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("iota");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
//qDebug() << "DataProxy_SQLite::getADIFQSO (IOTA): " << aux << QT_ENDL;
if (((aux.length())>=4) && ((aux.length())<=6))
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("iota_island_id");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
//qDebug() << "DataProxy_SQLite::getADIFQSO (IOTA_ID): " << aux << QT_ENDL;
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_iota");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if (((aux.length())>=4) && ((aux.length())<=6))
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_iota_island_id");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("k_index");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_itu_zone");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("lat");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("lon");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_lat");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_lon");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("lotw_qslrdate");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
date = util->getDateFromSQliteString(aux);
if (date.isValid())
{
aux = util->getADIFDateFromQDate(date);
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("lotw_qslsdate");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
date = util->getDateFromSQliteString(aux);
if (date.isValid())
{
aux = util->getADIFDateFromQDate(date);
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("lotw_qsl_rcvd");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ( ((aux.length())==1) && (aux!="N") )
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("lotw_qsl_sent");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ( ((aux.length())==1) && (aux!="N") )
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("clublog_qso_upload_date");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
date = util->getDateFromSQliteString(aux);
if (date.isValid())
{
aux = util->getADIFDateFromQDate(date);
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("clublog_qso_upload_status");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ( ((aux.length())==1) && ((aux!="Y") || (aux!="N") || (aux!="M")) )
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("qrzcom_qso_upload_date");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
date = util->getDateFromSQliteString(aux);
if (date.isValid())
{
aux = util->getADIFDateFromQDate(date);
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("qrzcom_qso_upload_status");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ( ((aux.length())==1) && ((aux!="Y") || (aux!="N") || (aux!="M")) )
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("max_bursts");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("ms_shower");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_city");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_cnty");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_country");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_cq_zone");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.toInt()>0) && (aux.toInt()<41))
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_name");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("name");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("operator");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if (util->isValidCall(aux))
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("owner_callsign");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if (util->isValidCall(aux))
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_postal_code");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_rig");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_sig");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_sota_ref");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_postal_code");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_state");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_street");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("notes");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
aux.replace("\n", "---");
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("nr_bursts");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("nr_pings");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("pfx");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("precedence");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("public_key");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("qslmsg");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("qslrdate");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
date = util->getDateFromSQliteString(aux);
if (date.isValid())
{
aux = util->getADIFDateFromQDate(date);
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("qslsdate");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString();
date = util->getDateFromSQliteString(aux);
if (date.isValid())
{
aux = util->getADIFDateFromQDate(date);
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("qsl_rcvd");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if (((aux.length())==1) && (aux!="N") )
{
ADIFqso.append("" + aux + " ");
nameCol = rec.indexOf("qsl_rcvd_via");
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())==1)
{
ADIFqso.append("" + aux + " ");
}
}
}
nameCol = rec.indexOf("qsl_sent");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if (((aux.length())==1) && (aux!="N") )
{
ADIFqso.append("" + aux + " ");
nameCol = rec.indexOf("qsl_sent_via");
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())==1)
{
ADIFqso.append("" + aux + " ");
}
}
}
nameCol = rec.indexOf("qsl_via");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("qso_complete");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("qso_random");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("qth");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("rst_sent");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("rst_rcvd");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("region");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("rig");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("rx_pwr");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if (((aux.length())>0) && (aux.toDouble()>0) )
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("tx_pwr");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ( ((aux.length())>0) && (aux.toDouble()>0))
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("sat_mode");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("sfi");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("sig");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("sig_info");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("silent_key");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("skcc");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("sota_ref");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("state");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("swl");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("ten_ten");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("ten_ten");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("uksmg");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("ve_prov");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_usaca_counties");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("usaca_counties");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("vucc_grids");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("my_vucc_grids");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("web");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0){
ADIFqso.append("" + aux + " ");
}
}
nameCol = rec.indexOf("lognumber");
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
if ((aux.length())>0)
{
ADIFqso.append("" + aux + " ");
}
}
ADIFqso.append("");
return ADIFqso;
}
bool DataProxy_SQLite::showInvalidCallMessage(const QString &_call){
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - Invalid call detected"));
QString aux = _call;
if (aux.length()<1)
{
aux = QString(tr("An empty callsign has been detected. Do you want to export this QSO anyway (click on Yes) or remove the field from the exported ADIF record?"));
}
else
{
aux = QString(tr("An invalid callsign has been detected %1. Do you want to export this callsign anyway (click on Yes) or remove the call from the exported log?").arg(aux));
}
msgBox.setText(aux);
msgBox.setInformativeText(tr("Exporting wrong calls may create problems in the applications you are potentially importing this logfile to. It may, however, be a good callsign that is wrongly identified by KLog as not valid."));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Yes:
// Yes was clicked
return true;
case QMessageBox::No:
// No Save was clicked
return false;
default:
// should never be reached
return false;
}
}
QList DataProxy_SQLite::getSatDXCCStats(int _log)
{
//qDebug() << Q_FUNC_INFO << ": log = " << QString::number(_log) << QT_ENDL;
QList _qsos;
QString stringQuery;
if (doesThisLogExist(_log))
{
//qDebug() << Q_FUNC_INFO << ": log exists " << QT_ENDL;
stringQuery = QString("SELECT call, qso_date, band.name, mode.name, entity.name, log.dxcc, lotw_qsl_rcvd, qsl_rcvd, sat_name from log, entity, band, mode where log.dxcc <>'' AND sat_name <>'' AND log.dxcc=entity.dxcc AND log.bandid=band.id AND log.modeid=mode.id AND lognumber='%1' ORDER BY entity.name").arg(_log);
}
else
{
//qDebug() << Q_FUNC_INFO << ": log does not exist " << QT_ENDL;
stringQuery = QString("SELECT call, qso_date, band.name, mode.name, entity.name, log.dxcc, lotw_qsl_rcvd, qsl_rcvd, sat_name from log, entity, band, mode where log.dxcc <>'' AND sat_name <>'' AND log.dxcc=entity.dxcc AND log.bandid=band.id AND log.modeid=mode.id ORDER BY entity.name");
}
QSqlQuery query;
bool sqlOK = query.exec(stringQuery);
if (!sqlOK)
{
//qDebug() << Q_FUNC_INFO << ": Query NOK" << QT_ENDL;
//qDebug() << Q_FUNC_INFO << ": " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << Q_FUNC_INFO << ": " << query.lastQuery() << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return _qsos;
}
else
{
while(query.next())
{
if (query.isValid())
{
int nameCol;
QSO *_qso = new QSO;
_qso->clear();
QSqlRecord rec = query.record();
nameCol = rec.indexOf("call");
_qso->setCall((query.value(nameCol)).toString());
nameCol = rec.indexOf("qso_date");
_qso->setDateTimeOn (util->getDateTimeFromSQLiteString((query.value(nameCol)).toString()));
nameCol = rec.indexOf("bandid");
//qDebug() << "DataProxy_SQLite::getGridStats: bandid" << QString::number((query.value(nameCol)).toInt()) << QT_ENDL;
_qso->setBand(query.value(2).toString());
//nameCol = rec.indexOf("modeid");
//qDebug() << Q_FUNC_INFO << ": modeid" << QString::number((query.value(nameCol)).toInt()) << QT_ENDL;
_qso->setMode(query.value(3).toString());
nameCol = rec.indexOf("sat_name");
_qso->setSatName((query.value(nameCol)).toString());
nameCol = rec.indexOf("log.dxcc");
_qso->setDXCC((query.value(nameCol)).toInt());
nameCol = rec.indexOf("lotw_qsl_rcvd");
_qso->setLoTWQSL_RCVD((query.value(nameCol)).toString());
nameCol = rec.indexOf("qsl_rcvd");
_qso->setQSL_RCVD((query.value(nameCol)).toString());
_qsos.append(_qso);
}
else
{
_qsos.clear();
query.finish();
return _qsos;
}
}
}
//qDebug() << Q_FUNC_INFO << "- END" << QT_ENDL;
return _qsos;
}
QList DataProxy_SQLite::getGridStats(int _log)
{
//qDebug() << Q_FUNC_INFO << ": log = " << QString::number(_log) << QT_ENDL;
QList _qsos;
QString stringQuery;
if (doesThisLogExist(_log))
{
//qDebug() << Q_FUNC_INFO << ":: log exists " << QT_ENDL;
stringQuery = QString("SELECT call, substr(gridsquare, 1, 4), bandid, modeid, lotw_qsl_rcvd, qsl_rcvd from log where gridsquare <>'' AND lognumber='%1'").arg(_log);
}
else
{
//qDebug() << Q_FUNC_INFO << ": log does not exist " << QT_ENDL;
stringQuery = QString("SELECT call, substr(gridsquare, 1, 4), bandid, modeid, lotw_qsl_rcvd, qsl_rcvd from log where gridsquare <>''");
}
QSqlQuery query;
bool sqlOK = query.exec(stringQuery);
if (!sqlOK)
{
//qDebug() << Q_FUNC_INFO << ": Query NOK" << QT_ENDL;
//qDebug() << Q_FUNC_INFO << ": " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << Q_FUNC_INFO << ": " << query.lastQuery() << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return _qsos;
}
else
{
while(query.next())
{
if (query.isValid())
{// call, substr(gridsquare, 1, 4), bandid, modeid, lotw_qsl_rcvd, qsl_rcvd
int nameCol;
QSO *_qso = new QSO;
_qso->clear();
QSqlRecord rec = query.record();
nameCol = rec.indexOf("call");
_qso->setCall((query.value(nameCol)).toString());
nameCol = rec.indexOf("substr(gridsquare, 1, 4)");
_qso->setGridSquare((query.value(nameCol)).toString());
nameCol = rec.indexOf("bandid");
//qDebug() << Q_FUNC_INFO << ": bandid" << QString::number((query.value(nameCol)).toInt()) << QT_ENDL;
_qso->setBand(getNameFromBandId((query.value(nameCol)).toInt()));
nameCol = rec.indexOf("modeid");
//qDebug() << Q_FUNC_INFO << ": modeid" << QString::number((query.value(nameCol)).toInt()) << QT_ENDL;
_qso->setMode(getNameFromModeId((query.value(nameCol)).toInt()));
nameCol = rec.indexOf("lotw_qsl_rcvd");
_qso->setLoTWQSL_RCVD((query.value(nameCol)).toString());
nameCol = rec.indexOf("qsl_rcvd");
_qso->setQSL_RCVD((query.value(nameCol)).toString());
_qsos.append(_qso);
//qDebug() << Q_FUNC_INFO << ": call: " << _call << QT_ENDL;
//qDebug() << Q_FUNC_INFO << ": band: " << _band << QT_ENDL;
//qDebug() << Q_FUNC_INFO << ": mode: " << _mode << QT_ENDL;
}
else
{
_qsos.clear();
query.finish();
return _qsos;
}
}
//qDebug() << "DataProxy_SQLite::addQSO: Query OK" << QT_ENDL;
}
//qDebug() << "DataProxy_SQLite::getGridStats - END" << QT_ENDL;
return _qsos;
}
QList DataProxy_SQLite::getSatGridStats(int _log)
{
//qDebug() << "DataProxy_SQLite::getGridStats: log = " << QString::number(_log) << QT_ENDL;
QList _qsos;
QString stringQuery;
if (doesThisLogExist(_log))
{
//qDebug() << "DataProxy_SQLite::getGridStats: log exists " << QT_ENDL;
stringQuery = QString("SELECT call, qso_date, bandid, modeid, substr(gridsquare, 1, 4), lotw_qsl_rcvd, qsl_rcvd, sat_name from log where gridsquare <>'' AND sat_name <>'' AND lognumber='%1'").arg(_log);
}
else
{
//qDebug() << "DataProxy_SQLite::getGridStats: log does not exist " << QT_ENDL;
stringQuery = QString("SELECT call, qso_date, bandid, modeid, substr(gridsquare, 1, 4), lotw_qsl_rcvd, qsl_rcvd, sat_name from log where gridsquare <>'' AND sat_name <>''");
}
QSqlQuery query;
bool sqlOK = query.exec(stringQuery);
if (!sqlOK)
{
//qDebug() << "DataProxy_SQLite::getGridStats: Query NOK" << QT_ENDL;
//qDebug() << "DataProxy_SQLite::getGridStats: " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::getGridStats: " << query.lastQuery() << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return _qsos;
}
else
{
while(query.next())
{
if (query.isValid())
{
int nameCol;
QSO *_qso = new QSO;
_qso->clear();
QSqlRecord rec = query.record();
nameCol = rec.indexOf("call");
_qso->setCall((query.value(nameCol)).toString());
nameCol = rec.indexOf("qso_date");
_qso->setDateTimeOn (util->getDateTimeFromSQLiteString((query.value(nameCol)).toString()));
nameCol = rec.indexOf("bandid");
//qDebug() << "DataProxy_SQLite::getGridStats: bandid" << QString::number((query.value(nameCol)).toInt()) << QT_ENDL;
_qso->setBand(getNameFromBandId((query.value(nameCol)).toInt()));
nameCol = rec.indexOf("modeid");
//qDebug() << "DataProxy_SQLite::getGridStats: modeid" << QString::number((query.value(nameCol)).toInt()) << QT_ENDL;
_qso->setMode(getNameFromModeId((query.value(nameCol)).toInt()));
nameCol = rec.indexOf("sat_name");
_qso->setSatName((query.value(nameCol)).toString());
nameCol = rec.indexOf("substr(gridsquare, 1, 4)");
_qso->setGridSquare((query.value(nameCol)).toString());
nameCol = rec.indexOf("lotw_qsl_rcvd");
_qso->setLoTWQSL_RCVD((query.value(nameCol)).toString());
nameCol = rec.indexOf("qsl_rcvd");
_qso->setQSL_RCVD((query.value(nameCol)).toString());
_qsos.append(_qso);
//qDebug() << "DataProxy_SQLite::getGridStats: call: " << _call << QT_ENDL;
//qDebug() << "DataProxy_SQLite::getGridStats: band: " << _band << QT_ENDL;
//qDebug() << "DataProxy_SQLite::getGridStats: mode: " << _mode << QT_ENDL;
}
else
{
_qsos.clear();
query.finish();
return _qsos;
}
}
//qDebug() << "DataProxy_SQLite::addQSO: Query OK" << QT_ENDL;
}
//qDebug() << "DataProxy_SQLite::getGridStats - END" << QT_ENDL;
return _qsos;
}
int DataProxy_SQLite::getFieldInBand(ValidFieldsForStats _field, const QString &_band, bool confirmedOnly, QString _mode, int _log)
{
//qDebug() << Q_FUNC_INFO << ": " << _band << "/" << _mode << "/" << QString::number(_log) ;
if ((!doesThisLogExist(_log)) && !(_log == -1))
{
//qDebug() << Q_FUNC_INFO << ": Exit no log";
return 0;
}
int bandId = getIdFromBandName (_band);
QString bandString = QString();
if (!(_band.toUpper () == "ALL"))
{
if (bandId<1)
{
//qDebug() << Q_FUNC_INFO << ": Exit band";
return 0;
}
bandString = QString(" AND bandid='%1'").arg(bandId);
}
QString field = QString();
QString specialField = QString();
switch (_field)
{
case DXCC:
field = "dxcc";
specialField = field + " <>'' AND dxcc<1000 AND dxcc>0";
break;
case GridSquare:
field = "gridsquare";
specialField = field + " <>''";
break;
}
QString stringQuery;
QSqlQuery query;
QString modeString = QString();
int modeId = getIdFromModeName(_mode);
if (_mode.toUpper() == "ALL")
{
//qDebug() << Q_FUNC_INFO << ": ALL Modes" ;
}
else if (util->isValidModeId(modeId))
{
//qDebug() << Q_FUNC_INFO << ": Valid Mode" ;
modeString = QString(" AND modeid='%1' ").arg(modeId);
}
else
{
//qDebug() << Q_FUNC_INFO << ": Mode not valid!" ;
return 0;
}
QString logString = QString();
if (!(_log == -1))
{
logString = QString(" AND lognumber='%1'").arg(_log);
}
QString confirmedString = QString();
if (confirmedOnly)
{
confirmedString = QString(" AND (lotw_qsl_rcvd='Y' OR qsl_rcvd='Y')");
}
stringQuery = QString("SELECT COUNT (DISTINCT %1) from log WHERE %2 %3 %4 %5 %6").arg(field).arg(specialField).arg(modeString).arg(bandString).arg(confirmedString).arg(logString);
//qDebug() << Q_FUNC_INFO << " : Query: " << stringQuery << QT_ENDL;
bool sqlOK = query.exec(stringQuery);
if (!sqlOK)
{
//qDebug() << Q_FUNC_INFO << " : Query NOK" << QT_ENDL;
//qDebug() << Q_FUNC_INFO << " : " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << Q_FUNC_INFO << " : " << query.lastQuery() << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return 0;
}
else
{
query.next();
if (query.isValid())
{
//qDebug() << Q_FUNC_INFO << " : " << QString::number((query.value(0)).toInt()) << QT_ENDL;
int v = (query.value(0)).toInt();
query.finish();
return v;
}
}
query.finish();
return 0;
}
int DataProxy_SQLite::addQSO(QSO &_qso)
{
//qDebug() << "DataProxy_SQLite::addQSO: " << _qso.getCall() << QT_ENDL;
qso = &_qso;
//qDebug() << "DataProxy_SQLite::addQSO: " << qso->getCall() << QT_ENDL;
//qso = _qso;
bool havePropMode = false;
bool haveRSTRX = false;
bool haveRSTTX = false;
QString stringQuery;
QString stringFields, stringData;
stringFields.clear();
stringData.clear();
//qDebug() << "DataProxy_SQLite::addQSO: QDateTime: " << util->getDateTimeSQLiteStringFromDateTime(qso->getDateTimeOn()) << QT_ENDL;
if (qso->getDateTimeOn().isValid())
{
stringFields.append("qso_date, ");
stringData = stringData + "'" + util->getDateTimeSQLiteStringFromDateTime(qso->getDateTimeOn()) + "', ";
}
else
{
//qDebug() << "DataProxy_SQLite::addQSO: END-1" << QT_ENDL;
return -1;
}
if (util->isValidCall(qso->getCall()))
{
stringFields.append("call, ");
stringData = stringData + "'" + qso->getCall() + "', ";
}
else
{
//qDebug() << "DataProxy_SQLite::addQSO: END-2" << QT_ENDL;
return -2;
}
//qDebug() << "DataProxy_SQLite::addQSO: Band: " << qso->getBand() << QT_ENDL;
if (util->isValidBandId(getIdFromBandName(qso->getBand())))
{
stringFields.append("bandid, ");
stringData = stringData + "'" + QString::number(getIdFromBandName(qso->getBand())) + "', ";
}
else
{
//qDebug() << "DataProxy_SQLite::addQSO: END-3" << QT_ENDL;
return -3;
}
if (util->isValidModeId(getIdFromModeName(qso->getMode())))
{
stringFields.append("modeid, ");
stringData = stringData + "'" + QString::number(getIdFromModeName(qso->getMode())) + "', ";
}
else
{
//qDebug() << "DataProxy_SQLite::addQSO: END-4" << QT_ENDL;
return -4;
}
if (util->isValidBandId(getIdFromBandName(qso->getBandRX())))
{
stringFields.append("band_rx, ");
stringData = stringData + "'" + QString::number(getIdFromBandName(qso->getBandRX())) + "', ";
}
if (qso->getFreqTX () > 0)
{
stringFields.append("freq, ");
stringData = stringData + "'" + QString::number(qso->getFreqTX()) + "', ";
}
if (qso->getFreqRX() > 0)
{
stringFields.append("freq_rx, ");
stringData = stringData + "'" + QString::number(qso->getFreqRX()) + "', ";
}
if (util->isValidCall(qso->getStationCallsign()))
{
stringFields.append("station_callsign, ");
stringData = stringData + "'" + qso->getStationCallsign() + "', ";
}
if (qso->getQSLRDate().isValid())
{
stringFields.append("qslrdate, ");
stringData = stringData + "'" + util->getDateSQLiteStringFromDate(qso->getQSLRDate()) + "', ";
}
//qDebug() << "DataProxy_SQLite::addQSO: getQSL_RCVD: " << qso->getQSL_RCVD() << QT_ENDL;
if (util->isValidQSL_Rcvd(qso->getQSL_RCVD()))
{
//qDebug() << "DataProxy_SQLite::addQSO: getQSL_RCVD: VALID " << QT_ENDL;
stringFields.append("qsl_rcvd, ");
stringData = stringData + "'" + qso->getQSL_RCVD() + "', ";
}
else
{
//qDebug() << "DataProxy_SQLite::addQSO: getQSL_RCVD: NOT valid" << QT_ENDL;
}
//qDebug() << "DataProxy_SQLite::addQSO: LOTW_QSL_RCVD: " << qso->getLoTWQSL_RCVD() << QT_ENDL;
if (util->isValidQSL_Rcvd(qso->getLoTWQSL_RCVD()))
{
//qDebug() << "DataProxy_SQLite::addQSO: LOTW_QSL_RCVD - VALID" << QT_ENDL;
stringFields.append("lotw_qsl_rcvd, ");
stringData = stringData + "'" + qso->getLoTWQSL_RCVD() + "', ";
}
else
{
//qDebug() << "DataProxy_SQLite::addQSO: LOTW_QSL_RCVD - NOT valid" << QT_ENDL;
}
//qDebug() << "DataProxy_SQLite::addQSO: LOTW_QSL_RCVD - END" << QT_ENDL;
if (qso->getLoTWQSLRDate().isValid())
{
stringFields.append("lotw_qslrdate, ");
stringData = stringData + "'" + util->getDateSQLiteStringFromDate(qso->getLoTWQSLRDate()) + "', ";
}
if (util->isValidQSL_Sent (qso->getLoTWQSL_SENT ()))
{
stringFields.append("lotw_qsl_sent, ");
stringData = stringData + "'" + qso->getLoTWQSL_SENT ()+ "', ";
}
if (qso->getLoTWQSLSDate().isValid())
{
stringFields.append("lotw_qslsdate, ");
stringData = stringData + "'" + util->getDateSQLiteStringFromDate(qso->getLoTWQSLSDate()) + "', ";
}
if ( getSatelliteName(qso->getSatName()).length()>0 )
{
stringFields.append("sat_name, ");
stringData = stringData + "'" + qso->getSatName() + "', ";
if (!havePropMode)
{
havePropMode = true;
stringFields.append("prop_mode, ");
stringData = stringData + "'SAT', ";
}
}
if ( !havePropMode && (qso->getPropMode().length()>0) )
{
stringFields.append("prop_mode, ");
stringData = stringData + "'" + qso->getPropMode() + "', ";
havePropMode = true;
}
if (!haveRSTRX)
{
stringFields.append("rst_rcvd, ");
stringData = stringData + "'" + util->getDefaultRST(qso->getMode())+ "', ";
}
if (!haveRSTTX)
{
stringFields.append("rst_sent, ");
stringData = stringData + "'" + util->getDefaultRST(qso->getMode())+ "', ";
}
if (qso->getLogId()>0)
{
stringFields.append("lognumber");
stringData = stringData + QString::number(qso->getLogId());
}
else
{
//qDebug() << "DataProxy_SQLite::addQSO: No LogNumber" << QT_ENDL;
return -2;
}
stringQuery = "INSERT INTO log (" + stringFields + ") values (" + stringData +")" ;
QSqlQuery query;
bool sqlOK = query.exec(stringQuery);
if (!sqlOK)
{
//qDebug() << "DataProxy_SQLite::addQSO: Query NOK" << QT_ENDL;
//qDebug() << "DataProxy_SQLite::addQSO: " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << "DataProxy_SQLite::addQSO: " << query.lastQuery() << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
return -1;
}
else
{
//qDebug() << "DataProxy_SQLite::addQSO: Query OK" << QT_ENDL;
}
//qDebug() << "DataProxy_SQLite::addQSO: " << stringQuery << QT_ENDL;
return getLastQSOid();
//return 1;
}
klog-1.8.6/tipsdialog.h 0000644 0001750 0001750 00000005450 14166020407 013756 0 ustar devel devel #ifndef TIPSDIALOG_H
#define TIPSDIALOG_H
/***************************************************************************
tipsdialog.h - description
-------------------
begin : sept 2019
copyright : (C) 2019 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
#include
#include
#include
#include
#include "klogdefinitions.h"
class TipsDialog : public QDialog
{
Q_OBJECT
public:
explicit TipsDialog(QWidget *parent = nullptr);
~TipsDialog();
void setSeverity(const DebugLogLevel _sev);
signals:
void debugLog (QString _func, QString _msg, DebugLogLevel _level);
void fillInQSOSignal();
void fillInDXCCSignal();
void findQSL2QSOSignal();
void fileExportToPrintSignal();
//void fileExportForLoTWSignal();
void fileOpenKLogFolderSignal();
void toolSendPendingQSLSignal();
void toolRecPendingQSLSignal();
void toolRecRecPendingQSLSignal();
void toolsUploadLoTWSignal();
private slots:
void slotPrevButtonClicked();
void slotNextButtonClicked();
void slotLinkActivated(const QString &_link);
private:
void setTip(const int _t);
QLabel *tipTextQLabel;
//QTextEdit *tipTextEdit;
QWidget *tip;
DebugLogLevel logSeverity;
int tipId, tipMax;
QString description;
};
#endif // TIPSDIALOG_H
klog-1.8.6/startwizard.h 0000644 0001750 0001750 00000011356 14166020407 014177 0 ustar devel devel #ifndef STARTWIZARD_H
#define STARTWIZARD_H
/***************************************************************************
startwizard.h - description
-------------------
begin : feb 2015
copyright : (C) 2015 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
#include
#include
#include
//#include
#include
#include
#include
#include
#include "downloadcty.h"
class FileOrMemoryPage;
class CTYPage;
class StartWizard : public QWizard
{
Q_OBJECT
public:
enum { Page_Intro, Page_Lic, Page_Mem, Page_CTY };
StartWizard(const QString &_klogDir, const QString &_softVersion, QWidget *parent = nullptr);
void setVersion(const QString &tversion);
//~StartWizard();
protected:
private slots:
void slotCancelWizard();
void slotRunInMemory(bool checked);
void slotButtonFinishedClicked();
private:
FileOrMemoryPage *fileOrMemoryPage;
CTYPage *ctyPage;
QString version;
bool inMemory;
QString klogDir;
};
class IntroPage : public QWizardPage
{
Q_OBJECT
public:
IntroPage(QWidget *parent = nullptr);
int nextId() const;
private:
QLabel *topLabel;
QTextEdit *welcomeBrowser;
};
class LicPage : public QWizardPage
{
Q_OBJECT
public:
LicPage(QWidget *parent = nullptr);
//void setNextButtonActive(const bool _active);
int nextId() const;
private:
QLabel *topLabel;
QTextEdit *licenseBrowser;
QCheckBox *aceptLicCheckBox;
};
/*
class FileOrMemoryPage : public QWizardPage
{
Q_OBJECT
public:
FileOrMemoryPage(QWidget *parent = 0);
int nextId() const;
//int nextId() const;
private slots:
void slotRunningModeSelectedFile(bool checked);
void slotRunningModeSelectedMemory(bool checked);
signals:
void exeInMemory(const bool mem);
private:
bool downloadCTYFile();
QLabel *topLabel;
QCheckBox *memoryQCheckbox;
QCheckBox *fileQCheckbox;
bool runInMemory;
};
*/
class CTYPage : public QWizardPage
{
Q_OBJECT
public:
CTYPage(const QString &_klogDir, const QString &_version, QWidget *parent = nullptr);
void updateProgress (qint64 v,qint64 t);
private slots:
/*
void slotCTYCheckButtonTogled(int state);
void slotDownloadCTY(bool checked);
void slotDownloadFinished();
void slotValueReturnedFromDownload(int value);
void slotDownloadButtonClicked();
*/
void slotUpdateDownloadProgress(qint64 received, qint64 total);
void slotDownloadButtonClicked();
void slotIgnoreDownloadButtonClicked();
void slotDownloadFinished(const int ret);
void slotDownloadError(const int ret);
void slotStopProgressBar();
signals:
void downloadTheFileSignal(const bool mem);
private:
bool prepareTheDownload();
bool doTheDownload();
//bool isComplete();
bool downloadCTYFile, CTYFileDownloaded;
int downloadValueResult;
//QString klogDir;
int total;
//bool completed;
DownLoadCTY *dl;
QLabel *topLabel;
QTextEdit *ctyBrowser;
QCheckBox *downloadCTYCheckBox;
QProgressBar *progressBar;
QPushButton *downloadButton, *ignoreDownloadButton;
QCheckBox *hiddenCheckBox;
};
#endif // STARTWIZARD_H
klog-1.8.6/infowidget.h 0000644 0001750 0001750 00000006665 14166020407 013767 0 ustar devel devel #ifndef INFOWIDGET_H
#define INFOWIDGET_H
/***************************************************************************
infowidget.h - description
-------------------
begin : ago 2017
copyright : (C) 2017 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
//
// This class implement the Info widget where the band, bearing, CQ & ITU zones.... are shown
//
#include
#include
#include "locator.h"
#include "awards.h"
#include "world.h"
#include "dataproxy_sqlite.h"
#include "dataproxy_sqlite.h"
class InfoWidget : public QWidget
{
Q_OBJECT
public:
InfoWidget(DataProxy_SQLite *dp, QWidget *parent = 0);
void createUI();
void clear();
void setCurrentLog(const int _log);
void setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default);
void setImperialSystem (const bool _imp);
void showInfo(const int _entity);
void showDistanceAndBearing(const QString &_locLocal, const QString &_loc2);
void showEntityInfo(const int _enti, int _cq=-1, int _itu=-1);
void setLocalLocator(const QString &_loc); //MAYBE NOT NEEDED
void setDXLocator(const QString &_loc); //MAYBE NOT NEEDED
private:
void clearBandLabels();
void clearInfoFromLocators();
QString getStyleColorToLabelFromBand(const QString &_b, const QString &_q);
QLabel *bandLabel1, *bandLabel2, *bandLabel3, *bandLabel4;
QLabel *bandLabel5, *bandLabel6, *bandLabel7, *bandLabel8;
QLabel *bandLabel9, *bandLabel10, *bandLabel11, *bandLabel12;
QLabel *continentLabel, *prefixLabel, *cqzLabel, *ituzLabel;
QLabel *gradShortLabel, *distShortLabel;
QLabel *gradLongLabel, *distLongLabel;
QLabel *distShortLabelN;
QLabel *distLongLabelN;
Awards *awards;
DataProxy_SQLite *dataProxy;
Locator *locator;
World *world;
int currentLog;
bool imperialSystem;
QString dxLocator, localLocator;
};
#endif // INFOWIDGET_H
klog-1.8.6/lotwutilities.cpp 0000644 0001750 0001750 00000070110 14166020407 015066 0 ustar devel devel /***************************************************************************
lotwutilities.cpp - description
-------------------
begin : apr 2020
copyright : (C) 2020 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
#include "lotwutilities.h"
#include
#include
#include
#include
//#include
LoTWUtilities::LoTWUtilities(const QString &_klogDir, const QString &_klogVersion, const QString &_parentFunction, DataProxy_SQLite *dp)
{
#ifdef QT_DEBUG
//qDebug() << Q_FUNC_INFO << ": " << _klogDir << " - " << _parentFunction;
#else
#endif
dataProxy = dp;
calendar = new QCalendarWidget;
util = new Utilities;
manager = new QNetworkAccessManager(this);
reply = nullptr;
file = new QFile;
//url = new QUrl;
klogDir = _klogDir;
klogVersion = _klogVersion;
downloadAborted = false;
stationCallsign.clear();
startDate.clear();
lotwQuery.clear();
lotwUser.clear();
lotwPassword.clear();
fileName = "lotwDownload.adi";
pDialog = new QProgressDialog(nullptr);
pDialog->cancel();
firstDate = QDate::currentDate();
calendar->setToolTip(tr("Double click on the date that you want to use as the start date for downloading QSOs."));
connect(calendar, SIGNAL(activated(QDate)), this, SLOT(slotCalendarDateSelected(QDate)));
//qDebug() << "LoTWUtilities::LoTWUtilities(): - END" << QT_ENDL;
}
LoTWUtilities::~LoTWUtilities()
{
//qDebug() << "LoTWUtilities::~LoTWUtilities" << QT_ENDL;
}
void LoTWUtilities::slotCalendarDateSelected(const QDate _d)
{
//qDebug() << "LoTWUtilities::slotCalendarDateSelected: " << _d.toString("yyyyMMdd") << QT_ENDL;
firstDate = _d;
startThefullDownload();
}
void LoTWUtilities::setFileName(const QString &_fn)
{
//qDebug() << "LoTWUtilities::setFileName: " << _fn << QT_ENDL;
if (_fn.length()>0)
{
fileName = _fn;
}
//qDebug() << "LoTWUtilities::setFileName - END" << QT_ENDL;
}
QString LoTWUtilities::getFileName()
{
//qDebug() << "LoTWUtilities::getFileName: " << fileName << QT_ENDL;
return fileName;
}
bool LoTWUtilities::selectQuery(const int _queryId)
{
//qDebug() << "LoTWUtilities::selectQuery: - Start: " << QString::number(_queryId) << QT_ENDL;
bool savePassword = true;
if (lotwPassword.length()<1)
{
savePassword = false;
bool ok;
lotwPassword = QInputDialog::getText(nullptr, tr("KLog - LoTW password needed"),
tr("Please enter your LoTW password: "), QLineEdit::Password, "", &ok);
if (!ok)
{
//qDebug() << "LoTWUtilities::selectQuery: - END 1" << QT_ENDL;
return false;
}
}
switch (_queryId)
{
case 1: // Normal query
lotwQuery = QString("https://lotw.arrl.org/lotwuser/lotwreport.adi?login=%1&password=%2&qso_query=1&qso_qsl=no&qso_owncall=%3&qso_startdate=%4").arg(lotwUser).arg(lotwPassword).arg(stationCallsign).arg(startDate);
break;
case 2:
lotwQuery = QString("https://lotw.arrl.org/lotwuser/lotwreport.adi?login=%1&password=%2&qso_query=1&qso_qsl=no&qso_owncall=%3&qso_startdate=%4").arg(lotwUser).arg(lotwPassword).arg(stationCallsign).arg(firstDate.toString("yyyyMMdd"));
break;
default:
{
lotwQuery = QString("https://lotw.arrl.org/lotwuser/lotwreport.adi?login=%1&password=%2&qso_query=1&qso_qsl=no&qso_owncall=%3&qso_startdate=%4").arg(lotwUser).arg(lotwPassword).arg(stationCallsign).arg(startDate);
}
}
if (!savePassword)
{// We delete the password as soon as possible if the user is not willing to save it
lotwPassword = QString();
}
url = QUrl(lotwQuery);
//qDebug() << "LoTWUtilities::selectQuery: - END" << QT_ENDL;
return true;
}
bool LoTWUtilities::setStationCallSign(const QString &_call)
{
//qDebug() << "LoTWUtilities::setStationCallSign: " << _call << QT_ENDL;
if (!util->isValidCall(_call))
{
//qDebug() << "LoTWUtilities::setStationCallSign: FALSE 1" << QT_ENDL;
return false;
}
if (((dataProxy->getStationCallSignsFromLog(-1)).contains(_call)))
{
//qDebug() << "LoTWUtilities::setStationCallSign: TRUE" << QT_ENDL;
stationCallsign = _call;
QDate date = dataProxy->getFirstQSODateFromCall(stationCallsign);
//qDebug() << "LoTWUtilities::setStationCallSign: Date: " << startDate << QT_ENDL;
if (date.isValid())
{
startDate = date.toString("yyyyMMdd");
//qDebug() << "LoTWUtilities::setStationCallSign: StartDate" << startDate << QT_ENDL;
}
else
{
startDate.clear();
//qDebug() << "LoTWUtilities::setStationCallSign: StartDate not valid Date" << QT_ENDL;
//qDebug() << Q_FUNC_INFO << "False 2 - END";
return false;
}
//qDebug() << "LoTWUtilities::setStationCallSign: startDate: " << startDate << QT_ENDL;
//qDebug() << Q_FUNC_INFO << "True 1 - END";
return true;
}
else if (dataProxy->getHowManyQSOInLog(-1) <1)
{
//qDebug() << "LoTWUtilities::setStationCallSign:TRUE Empty log" << QT_ENDL;
stationCallsign = _call;
//qDebug() << Q_FUNC_INFO << "True 2 - END";
return true;
}
else
{
//qDebug() << "LoTWUtilities::setStationCallSign: Not a single QSO in the log with that StationCallsign: " << stationCallsign << QT_ENDL;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - LoTW Station callsign"));
QString aux = QString(tr("There is not a single QSO in the log with that station callsign.") );
msgBox.setText(tr("Are you sure that you want to use that station callsign (%1)?").arg(_call));
msgBox.setDetailedText(aux);
msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
{
stationCallsign = _call;
//qDebug() << Q_FUNC_INFO << "True 3 - END";
return true;
}
else
{
//qDebug() << "LoTWUtilities::setStationCallSign: FALSE 2" << QT_ENDL;
//qDebug() << Q_FUNC_INFO << "FALSE 3 - END";
return false;
}
}
}
void LoTWUtilities::startRequest(QUrl url)
{
//qDebug() << "LoTWUtilities::startRequest: " << url.toString() << QT_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() << "LoTWUtilities::startRequest - 10" << QT_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() << "LoTWUtilities::startRequest: - END" << QT_ENDL;
}
int LoTWUtilities::download()
{
//qDebug() << "LoTWUtilities::download - Start" << QT_ENDL;
if (!selectQuery(-1))
{
//qDebug() << "LoTWUtilities::download - END-1" << QT_ENDL;
return -1;
}
//qDebug() << "LoTWUtilities::download: - 10" << QT_ENDL;
QFileInfo fileInfo(url.path());
//qDebug() << "LoTWUtilities::download: - 11" << QT_ENDL;
if (QFile::exists(fileName))
{
//qDebug() << "LoTWUtilities::download: - 12" << QT_ENDL;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
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);
msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
//qDebug() << "LoTWUtilities::download: - 13" << QT_ENDL;
if (ret == QMessageBox::No)
{
//qDebug() << "LoTWUtilities::download - END- 2" << QT_ENDL;
return -2;
}
}
//qDebug() << "LoTWUtilities::download: - 20 Filename: -" << fileName << "-" << QT_ENDL;
if (!file->isOpen())
{
//qDebug() << "LoTWUtilities::download: - 21 Filename: -" << QT_ENDL;
file->setFileName(fileName);
//qDebug() << "LoTWUtilities::download: - 22 Filename: -" << QT_ENDL;
}
//qDebug() << "LoTWUtilities::download: - 23 Filename: -" << QT_ENDL;
if (!file->open(QIODevice::WriteOnly)) /* Flawfinder: ignore */
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
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);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
//file->close();
//delete file;
//file = nullptr;
//qDebug() << "LoTWUtilities::download - END - 3" << QT_ENDL;
return -3;
}
//qDebug() << "LoTWUtilities::download: - 30" << QT_ENDL;
// used for progressDialog
// This will be set true when canceled from progress dialog
downloadAborted = false;
//qDebug() << "LoTWUtilities::download: - 31" << QT_ENDL;
//progressDialog = new QProgressDialog(nullptr);
//qDebug() << "LoTWUtilities::download: - 40" << QT_ENDL;
pDialog->setLabelText(tr("Downloading data to file: %1.").arg(fileName));
//qDebug() << "LoTWUtilities::download: - 41" << QT_ENDL;
pDialog->setWindowTitle(tr("KLog - LoTW download"));
//qDebug() << "LoTWUtilities::download: - 42" << QT_ENDL;
pDialog->setWindowModality(Qt::WindowModal);
//qDebug() << "LoTWUtilities::download: - 43" << QT_ENDL;
pDialog->reset();
//qDebug() << "LoTWUtilities::download: - 44" << QT_ENDL;
pDialog->setRange(0, 0);
//qDebug() << "LoTWUtilities::download: - 45" << QT_ENDL;
pDialog->setMinimumDuration(0);
//qDebug() << "LoTWUtilities::download: - 46" << QT_ENDL;
pDialog->show();
//qDebug() << "LoTWUtilities::download: - 47" << QT_ENDL;
connect(pDialog, SIGNAL(canceled()), this, SLOT(slotCancelDownload()));
//qDebug() << "LoTWUtilities::download: - 50" << QT_ENDL;
startRequest(url);
//qDebug() << "LoTWUtilities::download - END" << QT_ENDL;
return 1;
}
int LoTWUtilities::fullDownload()
{
//qDebug() << "LoTWUtilities::fullDownload" << QT_ENDL;
QDate date = dataProxy->getFirstQSODateFromCall(stationCallsign);
//qDebug() << "LoTWUtilities::fullDownload: Date: " << startDate << QT_ENDL;
if (date.isValid())
{
startDate = date.toString("yyyyMMdd");
//qDebug() << "LoTWUtilities::fullDownload: StartDate" << startDate << QT_ENDL;
}
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - LoTW Start date selection"));
QString aux = QString(tr("This is the first date of a QSO with the callsign %1 in this log If you think that in LoTW you may have previous QSOs, answer No.").arg(stationCallsign) );
msgBox.setText(tr("Do you want to use this date (%1) as start date?").arg(startDate));
msgBox.setDetailedText(aux);
msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
{
//qDebug() << "LoTWUtilities::fulldownload - Yes" << QT_ENDL;
firstDate = date;
startThefullDownload();
return 1;
}
calendar->setSelectedDate(firstDate);
calendar->setGridVisible(true);
calendar->setMaximumDate(QDate::currentDate());
calendar->show();
//qDebug() << "LoTWUtilities::fullDownload - END" << QT_ENDL;
return 2;
}
int LoTWUtilities::startThefullDownload()
{
//qDebug() << "LoTWUtilities::startThefulldownload - Start" << QT_ENDL;
if (calendar->isVisible())
{
calendar->close();
}
if (!selectQuery(2))
{
//qDebug() << "LoTWUtilities::startThefulldownload - END-1" << QT_ENDL;
return -1;
}
//qDebug() << "LoTWUtilities::startThefulldownload: - 10" << QT_ENDL;
QFileInfo fileInfo(url.path());
//qDebug() << "LoTWUtilities::startThefulldownload: - 11" << QT_ENDL;
if (QFile::exists(fileName))
{
//qDebug() << "LoTWUtilities::startThefulldownload: - 12" << QT_ENDL;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
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);
msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
//qDebug() << "LoTWUtilities::startThefulldownload: - 13" << QT_ENDL;
if (ret == QMessageBox::No)
{
//qDebug() << "LoTWUtilities::startThefulldownload - END- 2" << QT_ENDL;
return -2;
}
}
//qDebug() << "LoTWUtilities::startThefulldownload: - 20 Filename: -" << fileName << "-" << QT_ENDL;
if (!file->isOpen())
{
//qDebug() << "LoTWUtilities::startThefulldownload: - 21 Filename: -" << QT_ENDL;
file->setFileName(fileName);
//qDebug() << "LoTWUtilities::startThefulldownload: - 22 Filename: -" << QT_ENDL;
}
//qDebug() << "LoTWUtilities::startThefulldownload: - 23 Filename: -" << QT_ENDL;
if (!file->open(QIODevice::WriteOnly)) /* Flawfinder: ignore */
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
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);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
//file->close();
//delete file;
//file = nullptr;
//qDebug() << "LoTWUtilities::startThefulldownload - END - 3" << QT_ENDL;
return -3;
}
//qDebug() << "LoTWUtilities::startThefulldownload: - 30" << QT_ENDL;
// used for progressDialog
// This will be set true when canceled from progress dialog
downloadAborted = false;
//qDebug() << "LoTWUtilities::startThefulldownload: - 31" << QT_ENDL;
//progressDialog = new QProgressDialog(nullptr);
//qDebug() << "LoTWUtilities::startThefulldownload: - 40" << QT_ENDL;
pDialog->setLabelText(tr("Downloading data to file: %1.").arg(fileName));
//qDebug() << "LoTWUtilities::startThefulldownload: - 41" << QT_ENDL;
pDialog->setWindowTitle(tr("KLog - LoTW download"));
//qDebug() << "LoTWUtilities::startThefulldownload: - 42" << QT_ENDL;
pDialog->setWindowModality(Qt::WindowModal);
//qDebug() << "LoTWUtilities::startThefulldownload: - 43" << QT_ENDL;
pDialog->reset();
//qDebug() << "LoTWUtilities::startThefulldownload: - 44" << QT_ENDL;
pDialog->setRange(0, 0);
//qDebug() << "LoTWUtilities::startThefulldownload: - 45" << QT_ENDL;
pDialog->setMinimumDuration(0);
//qDebug() << "LoTWUtilities::startThefulldownload: - 46" << QT_ENDL;
pDialog->show();
//qDebug() << "LoTWUtilities::startThefulldownload: - 47" << QT_ENDL;
connect(pDialog, SIGNAL(canceled()), this, SLOT(slotCancelDownload()));
//qDebug() << "LoTWUtilities::startThefulldownload: - 50" << QT_ENDL;
startRequest(url);
//qDebug() << "LoTWUtilities::startThefulldownload - END" << QT_ENDL;
return 1;
}
void LoTWUtilities::slotDownloadProgress(qint64 bytesRead) {
//qDebug() << "LoTWUtilities::slotDownloadProgress: " << QString::number(bytesRead) << QT_ENDL;
if (downloadAborted)
{
//qDebug() << "LoTWUtilities::slotDownloadProgress: CANCELLED" << QT_ENDL;
return;
}
pDialog->setValue(bytesRead);
//qDebug() << "LoTWUtilities::slotDownloadProgress - END " << QT_ENDL;
}
void LoTWUtilities::slotReadyRead()
{
//qDebug() << "LoTWUtilities::slotReadyRead: " << reply->readLine() << QT_ENDL;
if (file)
{
file->write(reply->readAll());
}
//qDebug() << "LoTWUtilities::slotReadyRead - END" << QT_ENDL;
}
void LoTWUtilities::slotFinished()
{
//qDebug() << "LoTWUtilities::slotFinished - Started" << QT_ENDL;
// when canceled
if (downloadAborted)
{
if (file)
{
file->close();
file->remove();
//delete file;
//file = nullptr;
}
//reply->deleteLater();
pDialog->cancel();
reply->close();
//qDebug() << "LoTWUtilities::slotFinished - END Canceled" << QT_ENDL;
return;
}
//qDebug() << "LoTWUtilities::slotFinished - 10" << QT_ENDL;
// download finished normally
pDialog->cancel();
//qDebug() << "LoTWUtilities::slotFinished - 11" << QT_ENDL;
file->flush();
//qDebug() << "LoTWUtilities::slotFinished - 12" << QT_ENDL;
file->close();
//qDebug() << "LoTWUtilities::slotFinished - 13" << QT_ENDL;
// get redirection url
QVariant redirectionTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
//qDebug() << "LoTWUtilities::slotFinished - 14" << QT_ENDL;
if (reply->error())
{
file->remove();
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - LoTW Download error"));
QString aux;
msgBox.setText(tr("There was an error (%1) while downloading the file from LoTW.").arg(QString::number(reply->error())));
aux = QString(tr("The downloading error details are: %1") ).arg(reply->errorString());
msgBox.setDetailedText(aux);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
else if (!redirectionTarget.isNull())
{
//qDebug() << "LoTWUtilities::slotFinished - Redirection" << QT_ENDL;
QUrl newUrl = url.resolved(redirectionTarget.toUrl());
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
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);
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); /* Flawfinder: ignore */
file->resize(0);
startRequest(url);
//qDebug() << "LoTWUtilities::slotFinished - END-1" << QT_ENDL;
return;
}
}
else
{
//qDebug() << "LoTWUtilities::slotFinished: " << QT_ENDL;
}
//qDebug() << "LoTWUtilities::slotReadyRead - Going to parse ..." << QT_ENDL;
parseDownloadedFile(file->fileName());
//qDebug() << "LoTWUtilities::slotReadyRead - END" << QT_ENDL;
}
void LoTWUtilities::slotCancelDownload()
{
//qDebug() << "LoTWUtilities::slotCancelDownload - Start" << QT_ENDL;
downloadAborted = true;
reply->abort();
//qDebug() << "LoTWUtilities::slotCancelDownload - END" << QT_ENDL;
}
void LoTWUtilities::setUser(const QString &_call)
{
//qDebug() << "LoTWUtilities::setUser: " << _call << QT_ENDL;
lotwUser = _call;
//qDebug() << "LoTWUtilities::setUser: END" << QT_ENDL;
}
void LoTWUtilities::setPass(const QString &_pass)
{
//qDebug() << "LoTWUtilities::setPass: " << _pass << QT_ENDL;
lotwPassword = _pass;
//qDebug() << "LoTWUtilities::setPass: END" << QT_ENDL;
}
bool LoTWUtilities::getIsReady()
{
//qDebug() << "LoTWUtilities::getIsReady: user/station: -" << lotwUser <<"/" << stationCallsign << "-" << QT_ENDL;
if ((lotwUser.length()>1) && (stationCallsign.length()>1))
{
//qDebug() << "LoTWUtilities::getIsReady: true" << QT_ENDL;
return true;
}
else
{
//qDebug() << "LoTWUtilities::getIsReady: false" << QT_ENDL;
return false;
}
}
void LoTWUtilities::parseDownloadedFile(const QString &_fn)
{
//qDebug() << "LoTWUtilities::parseDownloadedFile: " << _fn << QT_ENDL;
QString _fileName = _fn;
QMessageBox msgBox;
QString aux;
QFile file( _fileName );
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) /* Flawfinder: ignore */
{
//qDebug() << "LoTWUtilities::parseDownloadedFile File not found" << _fileName << QT_ENDL;
msgBox.setIcon(QMessageBox::Warning);
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);
msgBox.setDetailedText(aux);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
//qDebug() << "LoTWUtilities::parseDownloadedFile: END-1" << QT_ENDL;
return ;
}
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() << "LoTWUtilities::parseDownloadedFile: lineU: " << lineU << QT_ENDL;
if (lineU.contains(""))
{
//qDebug() << "LoTWUtilities::parseDownloadedFile: EOH found" << QT_ENDL;
hasHeader = true;
}
//else if (lineU.contains("LOTW"))
//{
// //qDebug() << "LoTWUtilities::parseDownloadedFile: ProgramID found" << QT_ENDL;
// hasProgramID = true;
//}
//else if (lineU.contains(Lotw_owncall))
//{
// //qDebug() << "LoTWUtilities::parseDownloadedFile: OWNCALL found" << QT_ENDL;
// hasOwnCall = true;
//}
else if (lineU.contains("', QT_SKIP);
numQSO = (data.at(1)).toInt();
//qDebug() << "LoTWUtilities::parseDownloadedFile: QSOs: " << QString::number(numQSO) << QT_ENDL;
}
else if (lineU.contains("USERNAME/PASSWORD INCORRECT"))
{
userPasswordError = true;
}
}
// WE HAVE JUST FINISHED TO READ THE HEADER OR THE FILE, IF IT IS NOT AN ADIF
if (!hasHeader || (numQSO<1))
{
//qDebug() << "LoTWUtilities::parseDownloadedFile Header not found" << _fileName << QT_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() << "LoTWUtilities::parseDownloadedFile: END-2" << QT_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() << "LoTWUtilities::parseDownloadedFile: END-2" << QT_ENDL;
return ;
}
//file.seek(startOfFile);
emit actionProcessLoTWDownloadedFile(_fileName);
}
//Procesar los QSOs y meterlos en una tabla? o en un QStringList o alguna otra estructura
//qDebug() << "LoTWUtilities::parseDownloadedFile - END" << QT_ENDL;
}
/*void LoTWUtilities::showMessage(const int _messageIcon, const QString &_msg, const QString &_msgExt)
{
}
*/
klog-1.8.6/NEWS 0000644 0001750 0001750 00000000175 14166020407 012144 0 ustar devel devel Look at https://www.klog.xyz for NEWS of KLog.
You can also check the Changelog file for the latest updates in the software.
klog-1.8.6/klog.rc 0000644 0001750 0001750 00000000073 14166020407 012724 0 ustar devel devel IDI_ICON1 ICON DISCARDABLE "klog.ico"
klog-1.8.6/inputwidgets/ 0000755 0001750 0001750 00000000000 14166020421 014164 5 ustar devel devel klog-1.8.6/inputwidgets/mainwindowinputqsl.h 0000644 0001750 0001750 00000007106 14166020407 020321 0 ustar devel devel #ifndef MAINWINDOWINPUTQSL_H
#define MAINWINDOWINPUTQSL_H
/***************************************************************************
mainwindowinputqsl.h - description
-------------------
begin : jun 2017
copyright : (C) 2017 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
//
// This class implement the tab of the mainwindow that supports the QSL options
//
#include
#include
#include
#include "../dataproxy_sqlite.h"
#include "../utilities.h"
class MainWindowInputQSL : public QWidget
{
Q_OBJECT
public:
explicit MainWindowInputQSL(DataProxy_SQLite *dp, QWidget *parent = nullptr);
~MainWindowInputQSL();
QString getQSLRecStatus();
QString getQSLSenStatus();
QString getSentVia();
QString getRecVia();
QString getQSLVia();
QString getQSLMsg();
void setQSLRecStatus(const QString &_qs);
void setQSLSenStatus(const QString &_qs);
void setQSLRecVia(const QString &_qs);
void setQSLSenVia(const QString &_qs);
void setQSLVia(const QString &_qs, QColor qColor=Qt::black);
void setQSLMsg(const QString &_qs);
QDate getQSLRecDate();
QDate getQSLSenDate();
void setQSLRecDate(const QDate _qs);
void setQSLSenDate(const QDate _qs);
void clear();
void qslViaClear();
signals:
void returnPressed();
private slots:
void slotQSLViaTextChanged();
void slotQSLSentComboBoxChanged();
void slotQSLRecvComboBoxChanged();
void slotQSLViaLineEditReturnPressed();
/*
void sloteQSLRecvComboBoxChanged();
void sloteQSLSentComboBoxChanged();
void slotLotwRecvComboBoxChanged();
void slotLotwSentComboBoxChanged();
*/
private:
void createUI();
void setDefaultData();
QComboBox *qslSentComboBox, *qslRecComboBox, *qslSentViaComboBox, *qslRecViaComboBox;
QDateEdit *qslSentQDateEdit, *qslRecQDateEdit;
QTextEdit *qslmsgTextEdit;
QLineEdit *qslViaLineEdit;
DataProxy_SQLite *dataProxy;
Utilities *util;
QStringList qslSentStatusList, qslRcvdStatusList, qslViaList;
QPalette palette; // To color some widgets
};
#endif // MAINWINDOWINPUTQSL_H
klog-1.8.6/inputwidgets/mainwindowinputqso.cpp 0000644 0001750 0001750 00000051610 14166020421 020652 0 ustar devel devel /***************************************************************************
mainwindowinputqso.cpp - description
-------------------
begin : may 2021
copyright : (C) 2021 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
//
// This class implement the tab of the mainwindow that supports the QSL options
//
#include "mainwindowinputqso.h"
MainWindowInputQSO::MainWindowInputQSO(DataProxy_SQLite *dp, QWidget *parent) :
QWidget(parent)
{
//qDebug() << "MainWindowInputQSO::MainWindowInputQSO" << QT_ENDL;
dataProxy = dp;
locator = new Locator();
nameLineEdit = new QLineEdit;
qthLineEdit = new QLineEdit;
locatorLineEdit = new QLineEdit;
rstTXLineEdit = new QLineEdit;
rstRXLineEdit = new QLineEdit;
txFreqSpinBox = new QDoubleSpinBox;
rxFreqSpinBox = new QDoubleSpinBox;
splitCheckBox = new QCheckBox;
rxPowerSpinBox = new QDoubleSpinBox;
dataProxy = dp;
createUI();
setDefaultData();
//installEventFilter (this);
clear();
//qDebug() << "MainWindowInputQSO::MainWindowInputQSO - END" << QT_ENDL;
}
MainWindowInputQSO::~MainWindowInputQSO()
{
delete(locator);
}
void MainWindowInputQSO::setModifying(const bool _m)
{
modify = _m;
}
void MainWindowInputQSO::createUI()
{
rstTXLineEdit->setToolTip(tr("TX RST."));
rstRXLineEdit->setToolTip(tr("RX RST."));
txFreqSpinBox->setToolTip(tr("TX Frequency in MHz."));
rxFreqSpinBox->setToolTip(tr("RX Frequency in MHz."));
rxPowerSpinBox->setToolTip(tr("Power used by the contacted station."));
nameLineEdit->setToolTip(tr("Name of the contacted operator."));
qthLineEdit->setToolTip(tr("QTH of the contacted station."));
locatorLineEdit->setToolTip(tr("Locator of the contacted station."));
rxPowerSpinBox->setDecimals(2);
rxPowerSpinBox->setMaximum(9999);
rxPowerSpinBox->setSuffix(" " + tr("Watts"));
txFreqSpinBox->setDecimals(3);
txFreqSpinBox->setMaximum(99999);
txFreqSpinBox->setSuffix(" " + tr("MHz"));
rxFreqSpinBox->setDecimals(3);
rxFreqSpinBox->setMaximum(99999);
rxFreqSpinBox->setSuffix(" " + tr("MHz"));
splitCheckBox->setText(tr("Split", "Translator: Split is a common hamradio term. Do not translate unless you are sure."));
splitCheckBox->setChecked(false);
QLabel *nameLabel = new QLabel(this);
nameLabel->setText(tr("Name"));
nameLabel->setAlignment(Qt::AlignVCenter| Qt::AlignCenter);
QLabel *qthLabel = new QLabel(this);
qthLabel->setText(tr("QTH"));
qthLabel->setAlignment(Qt::AlignVCenter| Qt::AlignCenter);
QLabel *locLabel = new QLabel(this);
locLabel->setText(tr("DX Locator"));
locLabel->setAlignment(Qt::AlignVCenter| Qt::AlignCenter);
QLabel *rxPowerSpinBoxLabelN = new QLabel(this);
rxPowerSpinBoxLabelN->setText(tr("Power(rx)"));
rxPowerSpinBoxLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignCenter);
QLabel *rstTxLabelN = new QLabel(this);
rstTxLabelN->setText(tr("RST(tx)"));
rstTxLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignCenter);
QLabel *rstRxLabelN = new QLabel(this);
rstRxLabelN->setText(tr("RST(rx)"));
rstRxLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignCenter);
QGridLayout *RSTLayout = new QGridLayout;
RSTLayout->addWidget(rstTxLabelN, 0, 0);
RSTLayout->addWidget(rstTXLineEdit, 1, 0);
RSTLayout->addWidget(rstRxLabelN, 0, 1);
RSTLayout->addWidget(rstRXLineEdit, 1, 1);
QVBoxLayout *qthLayout = new QVBoxLayout;
qthLayout->addWidget(qthLabel);
qthLayout->addWidget(qthLineEdit);
QVBoxLayout *rstQTHLayout = new QVBoxLayout;
rstQTHLayout->addLayout(RSTLayout);
rstQTHLayout->addLayout(qthLayout);
QLabel *txfreqLabelN = new QLabel(this);
txfreqLabelN->setText(tr("Freq TX"));
txfreqLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignCenter);
txfreqLabelN->setAlignment(Qt::AlignLeft);
QLabel *rxfreqLabelN = new QLabel(this);
rxfreqLabelN->setText(tr("Freq RX"));
rxfreqLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignCenter);
rxfreqLabelN->setAlignment(Qt::AlignRight);
QHBoxLayout *freqTitleLayout = new QHBoxLayout;
freqTitleLayout->addWidget(txfreqLabelN);
freqTitleLayout->addWidget(splitCheckBox);
freqTitleLayout->addWidget(rxfreqLabelN);
QHBoxLayout *freqDataLayout = new QHBoxLayout;
freqDataLayout->addWidget(txFreqSpinBox);
//freqDataLayout->addStretch(1);
freqDataLayout->addWidget(rxFreqSpinBox);
QVBoxLayout *freqLayout = new QVBoxLayout;
freqLayout->addLayout(freqTitleLayout);
freqLayout->addLayout(freqDataLayout);
QVBoxLayout *locVLayout = new QVBoxLayout;
locVLayout->addWidget(locLabel);
locVLayout->addWidget(locatorLineEdit);
QVBoxLayout *freqLocLayout = new QVBoxLayout;
freqLocLayout->addLayout(freqLayout);
freqLocLayout->addLayout(locVLayout);
QHBoxLayout *rstfreqLayout = new QHBoxLayout;
rstfreqLayout->addLayout(rstQTHLayout);
rstfreqLayout->addLayout(freqLocLayout);
QVBoxLayout *rxPowerLayout = new QVBoxLayout;
rxPowerLayout->addWidget(rxPowerSpinBoxLabelN);
rxPowerLayout->addWidget(rxPowerSpinBox);
QVBoxLayout *nameLayout = new QVBoxLayout;
nameLayout->addWidget(nameLabel);
nameLayout->addWidget(nameLineEdit);
QVBoxLayout *rxPwrLayout = new QVBoxLayout;
rxPwrLayout->addWidget(rxPowerSpinBoxLabelN);
rxPwrLayout->addWidget(rxPowerSpinBox);
QHBoxLayout *namePwrHLayout = new QHBoxLayout;
namePwrHLayout->addLayout(nameLayout);
namePwrHLayout->addLayout(rxPwrLayout);
QVBoxLayout *namePwrLayout = new QVBoxLayout;
namePwrLayout->addStretch(1);
namePwrLayout->addLayout(namePwrHLayout);
namePwrLayout->addStretch(5);
QVBoxLayout *qsoInputTabWidgetMainLayout = new QVBoxLayout;
qsoInputTabWidgetMainLayout->addLayout(rstfreqLayout);
qsoInputTabWidgetMainLayout->addLayout(namePwrLayout);
//qsoInputTabWidgetMainLayout->setSizeConstraint(QLayout::SetFixedSize);
setLayout(qsoInputTabWidgetMainLayout);
connect(rstTXLineEdit, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed() ) );
connect(rstRXLineEdit, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed() ) );
connect(locatorLineEdit, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed() ) );
connect(qthLineEdit, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed() ) );
connect(nameLineEdit, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed() ) );
connect(locatorLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotLocatorTextChanged() ) );
connect(txFreqSpinBox, SIGNAL(valueChanged(double)), this, SLOT(slotFreqTXChanged(double)) ) ;
connect(rxFreqSpinBox, SIGNAL(valueChanged(double)), this, SLOT(slotFreqRXChanged(double)) ) ;
connect(splitCheckBox, SIGNAL(clicked()), this, SLOT(slotSplitClicked()) ) ;
QWidget::setTabOrder (rstTXLineEdit, rstRXLineEdit);
QWidget::setTabOrder (rstRXLineEdit, nameLineEdit);
QWidget::setTabOrder (nameLineEdit, qthLineEdit);
QWidget::setTabOrder (qthLineEdit, locatorLineEdit);
QWidget::setTabOrder (locatorLineEdit, rxPowerSpinBox);
}
void MainWindowInputQSO::setDefaultData()
{
palRed.setColor(QPalette::Text, Qt::red);
palBlack.setColor(QPalette::Text, Qt::black);
palWhite.setColor(QPalette::Text, Qt::white);
rxFreqBeingAutoChanged = false;
txFreqBeingAutoChanged = false;
isSATPropagation = false;
propMode = QString();
freqTX = 0.0;
freqRX = 0.0;
modify = false;
}
void MainWindowInputQSO::clear()
{
//qDebug() << Q_FUNC_INFO ;
qthLineEdit->clear();
nameLineEdit->clear();
locatorLineEdit->clear();
rxPowerSpinBox->setValue(0);
modify = false;
}
void MainWindowInputQSO::cleanQRZCOM()
{
//qDebug() << Q_FUNC_INFO ;
qthLineEdit->clear();
nameLineEdit->clear();
locatorLineEdit->clear();
}
void MainWindowInputQSO::clearName()
{
nameLineEdit->clear();
}
void MainWindowInputQSO::clearQTH()
{
qthLineEdit->clear();
}
void MainWindowInputQSO::clearDXLocator()
{
//qDebug() << Q_FUNC_INFO ;
locatorLineEdit->clear ();
}
void MainWindowInputQSO::slotReturnPressed()
{
emit returnPressed();
}
void MainWindowInputQSO::slotLocatorTextChanged()
{//TO BE REMOVED ONCE InfoWidget is FINISHED - At least modified
//qDebug() << Q_FUNC_INFO << ": " << locatorLineEdit->text() << QT_ENDL;
int cursorP = locatorLineEdit->cursorPosition();
locatorLineEdit->setText((util->getClearSQLi(locatorLineEdit->text())).toUpper());
if ( locator->isValidLocator((locatorLineEdit->text()).toUpper()) || locatorLineEdit->text ().isEmpty ())
{
//qDebug() << Q_FUNC_INFO << ": VALID: " << locatorLineEdit->text() << QT_ENDL;
setPaletteRightDXLocator(true);
emit dxLocatorChanged (locatorLineEdit->text());
//dxLocator = (locatorLineEdit->text());
//infoWidget->showDistanceAndBearing(myDataTabWidget->getMyLocator(), dxLocator);
//satTabWidget->setLocator(dxLocator);
locatorLineEdit->setToolTip(tr("DX QTH locator."));
//qDebug() << Q_FUNC_INFO << ": " << locator->getLat(locatorLineEdit->text()) << QT_ENDL;
//qDebug() << Q_FUNC_INFO << ": LON: " << locator->getLon(locatorLineEdit->text()) << QT_ENDL;
}
else
{
//qDebug() << Q_FUNC_INFO << ": NOT VALID: " << locatorLineEdit->text() << QT_ENDL;
setPaletteRightDXLocator(false);
locatorLineEdit->setToolTip(tr("DX QTH locator. Format should be Maidenhead like IN70AA up to 10 characters."));
locatorLineEdit->setCursorPosition(cursorP);
return;
}
locatorLineEdit->setCursorPosition(cursorP);
}
QString MainWindowInputQSO::getDXLocator()
{
//qDebug() << Q_FUNC_INFO << " - returning: " << locatorLineEdit->text ();
return locatorLineEdit->text();
}
void MainWindowInputQSO::setDXLocator(const QString &_loc)
{
//qDebug() << Q_FUNC_INFO << ": " << _loc;
if (locator->isValidLocator (_loc))
{
locatorLineEdit->setText (_loc.toUpper ());
}
}
QString MainWindowInputQSO::getName()
{
return nameLineEdit->text ();
}
void MainWindowInputQSO::setName(const QString &_st)
{
nameLineEdit->setText (_st);
}
double MainWindowInputQSO::getTXFreq()
{
return txFreqSpinBox->value();
}
void MainWindowInputQSO::setTXFreq(const double _ft)
{
//qDebug() << Q_FUNC_INFO << ": " << QString::number(_ft) << QT_ENDL;
if ( (_ft >= double(0)) && (_ft <= txFreqSpinBox->maximum()))
{
//qDebug() << Q_FUNC_INFO << ": defining FR: " << QString::number(_ft) << QT_ENDL;
txFreqSpinBox->setValue(_ft);
}
else
{
//qDebug() << Q_FUNC_INFO << ": defining FR: 0" << QT_ENDL;
txFreqSpinBox->setValue(0);
}
//qDebug() << Q_FUNC_INFO << QT_ENDL;
}
double MainWindowInputQSO::getRXFreq()
{
return rxFreqSpinBox->value();
}
void MainWindowInputQSO::setRXFreq(const double _ft)
{
if ( (_ft >= double(0)) && (_ft <= rxFreqSpinBox->maximum()))
{
rxFreqSpinBox->setValue(_ft);
}
else
{
rxFreqSpinBox->setValue(0);
}
}
double MainWindowInputQSO::getRXPwr()
{
return rxPowerSpinBox->value();
}
void MainWindowInputQSO::setRXPwr(const double _pw)
{
if (_pw>=0)
{
rxPowerSpinBox->setValue(_pw);
}
}
QString MainWindowInputQSO::getQTH()
{
return qthLineEdit->text();
}
void MainWindowInputQSO::setQTH(const QString &_st)
{
qthLineEdit->setText(_st);
}
QString MainWindowInputQSO::getRSTTX()
{
return rstTXLineEdit->text();
}
void MainWindowInputQSO::setRSTTX(const QString &_st)
{
rstTXLineEdit->setText (_st);
}
QString MainWindowInputQSO::getRSTRX()
{
return rstRXLineEdit->text();
}
void MainWindowInputQSO::setRSTRX(const QString &_st)
{
rstRXLineEdit->setText (_st);
}
void MainWindowInputQSO::setRSTToMode(const QString &_m, const bool _reading)
{
//qDebug() << Q_FUNC_INFO << ": " << _m ;
if ((_m == "SSB") || (_m== "LSB") || (_m=="USB") || (_m == "FM") || (_m == "AM") )
{
//qDebug() << Q_FUNC_INFO << ": Detected SSB/LSB/USB" << QT_ENDL;
rstTXLineEdit->setInputMask("#DD");
rstRXLineEdit->setInputMask("#DD");
//rstTXLineEdit->setText("59");
//rstRXLineEdit->setText("59");
rstTXLineEdit->setMaxLength(2);
rstRXLineEdit->setMaxLength(2);
}
else if ((_m == "CW") || (_m == "RTTY"))
{
rstTXLineEdit->setInputMask("DDD");
rstRXLineEdit->setInputMask("DDD");
//rstTXLineEdit->setText("599");
//rstRXLineEdit->setText("599");
rstTXLineEdit->setMaxLength(3);
rstRXLineEdit->setMaxLength(3);
}
else if (_m == "PSK31")
{
rstTXLineEdit->setInputMask("#DD0");
rstRXLineEdit->setInputMask("#DD0");
//rstTXLineEdit->setText("599");
//rstRXLineEdit->setText("599");
rstTXLineEdit->setMaxLength(4);
rstRXLineEdit->setMaxLength(4);
}
else if ( (_m.contains("FT", Qt::CaseInsensitive)) || (_m.contains("JT", Qt::CaseInsensitive)) || (_m.contains("QRA64", Qt::CaseInsensitive)) || (_m.contains("JS", Qt::CaseInsensitive)))
{
rstTXLineEdit->setInputMask("#99");
rstRXLineEdit->setInputMask("#99");
//rstTXLineEdit->setText("0");
//rstRXLineEdit->setText("0");
rstTXLineEdit->setMaxLength(3);
rstRXLineEdit->setMaxLength(3);
}
else
{ // By default SSB RST is configured but anything could be added
rstTXLineEdit->setInputMask("#xxx");
rstRXLineEdit->setInputMask("#xxx");
//rstTXLineEdit->setText("59");
//rstRXLineEdit->setText("59");
rstTXLineEdit->setMaxLength(4);
rstRXLineEdit->setMaxLength(4);
}
if (!_reading)
{
//qDebug() << Q_FUNC_INFO << ": reading the UI" << QT_ENDL;
rstTXLineEdit->setText(util->getDefaultRST(_m));
rstRXLineEdit->setText(util->getDefaultRST(_m));
}
}
bool MainWindowInputQSO::getDarkMode()
{
if (nameLineEdit->palette().color(QPalette::Base) == "#646464")
{
return true;
}
else
{
return false;
}
}
void MainWindowInputQSO::setPaletteRightName(const bool _ok)
{
if (_ok)
{
if (getDarkMode())
{
nameLineEdit->setPalette (palWhite);
}
else
{
nameLineEdit->setPalette (palBlack);
}
}
else
{
nameLineEdit->setPalette (palRed);
}
}
void MainWindowInputQSO::setPaletteRightQTH(const bool _ok)
{
if (_ok)
{
if (getDarkMode())
{
qthLineEdit->setPalette (palWhite);
}
else
{
qthLineEdit->setPalette (palBlack);
}
}
else
{
qthLineEdit->setPalette (palRed);
}
}
void MainWindowInputQSO::setPaletteRightDXLocator(const bool _ok)
{
if (_ok)
{
if (getDarkMode())
{
locatorLineEdit->setPalette (palWhite);
}
else
{
locatorLineEdit->setPalette (palBlack);
}
}
else
{
locatorLineEdit->setPalette (palRed);
}
}
void MainWindowInputQSO::setPropModeFromSat(const QString &_p)
{
//qDebug() << Q_FUNC_INFO << ": " << _p << QT_ENDL;
propMode = _p;
if (propMode == "SAT")
{
splitCheckBox->setChecked (true);
}
else
{
splitCheckBox->setChecked (false);
}
}
void MainWindowInputQSO::slotFreqTXChanged (double _f)
{
//qDebug() << Q_FUNC_INFO << ": " << QString::number(_f) << QT_ENDL;
if (util->isSameFreq (_f, freqTX))
{
//qDebug() << Q_FUNC_INFO << ": Same Freq return" << QT_ENDL;
return;
}
freqTX = _f;
int bandId = dataProxy->getBandIdFromFreq(_f);
if (bandId > 1)
{ // If the freq belongs to one ham band
txFreqSpinBox->setToolTip(tr("TX Frequency in MHz."));
if (getDarkMode())
{
txFreqSpinBox->setPalette(palWhite);
}
else
{
txFreqSpinBox->setPalette(palBlack);
}
//qDebug() << Q_FUNC_INFO << ": emitting: " << QString::number(_f) << QT_ENDL;
emit txFreqChanged (_f);
}
else
{
txFreqSpinBox->setToolTip(tr("TX Frequency in MHz.\nFrequency is not in a hamradio band!"));
txFreqSpinBox->setPalette(palRed);
//qDebug() << Q_FUNC_INFO << ":RED - Not in band " << QT_ENDL;
}
if ((!splitCheckBox->isChecked()) || modify )
{
rxFreqSpinBox->setValue (_f);
//qDebug() << Q_FUNC_INFO << ": copying to RX Freq " << QT_ENDL;
}
//qDebug() << Q_FUNC_INFO << " - END" << QT_ENDL;
setSplitCheckBox();
}
void MainWindowInputQSO::slotSplitClicked()
{
if ((!splitCheckBox->isChecked()) )
{
rxFreqSpinBox->setValue(txFreqSpinBox->value());
}
}
void MainWindowInputQSO::slotFreqRXChanged(double _f)
{
if (util->isSameFreq (_f, freqRX))
{
return;
}
freqRX = _f;
int bandId = dataProxy->getBandIdFromFreq(_f);
if (bandId > 1)
{ // If the freq belongs to one ham band
if (getDarkMode())
{
rxFreqSpinBox->setPalette(palWhite);
}
else
{
rxFreqSpinBox->setPalette(palBlack);
}
rxFreqSpinBox->setToolTip(tr("RX Frequency in MHz."));
emit rxFreqChanged(rxFreqSpinBox->value());
}
else
{
rxFreqSpinBox->setToolTip(tr("RX Frequency in MHz.\nFrequency is not in a hamradio band!"));
rxFreqSpinBox->setPalette(palRed);
//qDebug() << "MainWindow::slotFreqRXChanged Freq is not in ANY ham band" << QT_ENDL;
}
if ((!splitCheckBox->isChecked()) && !modify)
{
txFreqSpinBox->setValue (_f);
}
/*
int bandId = dataProxy->getBandIdFromFreq(_f);
if (bandId > 1)
{ // If the freq belongs to one ham band
rxFreqSpinBox->setPalette(palBlack);
rxFreqSpinBox->setToolTip(tr("RX Frequency in MHz."));
emit rxFreqChanged(rxFreqSpinBox->value());
}
else
{
rxFreqSpinBox->setToolTip(tr("RX Frequency in MHz.\nFrequency is not in a hamradio band!"));
rxFreqSpinBox->setPalette(palRed);
//qDebug() << "MainWindow::slotFreqRXChanged Freq is not in ANY ham band" << QT_ENDL;
}
if (!rxFreqBeingAutoChanged)
{
//qDebug() << "MainWindow::slotFreqTXChanged: Updating SAT Downlink" << QT_ENDL;
emit rxFreqChangedForSat(rxFreqSpinBox->value());
}
*/
//qDebug() << "MainWindow::slotFreqRXChanged: END" << QT_ENDL;
setSplitCheckBox();
}
void MainWindowInputQSO::setSplitCheckBox()
{
if (util->isSameFreq(txFreqSpinBox->value(), rxFreqSpinBox->value()))
{
splitCheckBox->setChecked(false);
}
else
{
splitCheckBox->setChecked(true);
}
}
void MainWindowInputQSO::receiveFocus()
{
//qDebug() << Q_FUNC_INFO;
rstTXLineEdit->setFocus ();
}
bool MainWindowInputQSO::eventFilter (QObject *object, QEvent *event)
{
if (!(event->type() == QEvent::Paint ))
{
//qDebug() << Q_FUNC_INFO << ": " << QString::number(event->type ());
}
if ((event->type() == QEvent::KeyPress) || (event->type() == QEvent::ShortcutOverride)) {
//qDebug() << Q_FUNC_INFO << "KEY PRESSED";
QKeyEvent *ke = static_cast(event);
if (ke->key() == Qt::Key_Tab) {
//qDebug() << Q_FUNC_INFO << "KEY PRESSED TAB";
if (rxPowerSpinBox->hasFocus())
{
//qDebug() << Q_FUNC_INFO << "emitting to hand over to mainQSO Input";
emit handOverFocusSignal();
}
// special tab handling here
return true;
}
}
return QWidget::event(event);
}
klog-1.8.6/inputwidgets/mainwindowinputcomment.h 0000644 0001750 0001750 00000004711 14166020407 021163 0 ustar devel devel #ifndef MAINWINDOWINPUTCOMMENT_H
#define MAINWINDOWINPUTCOMMENT_H
/***************************************************************************
mainwindowminputcomment.h - description
-------------------
begin : ago 2016
copyright : (C) 2016 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
//
// This class implement the tab of the mainwindow that supports the Comment
//
#include
#include
class MainWindowInputComment : public QWidget
{
Q_OBJECT
public:
explicit MainWindowInputComment(QWidget *parent = nullptr);
~MainWindowInputComment();
void createUI();
void setData(const QString &_comment);
QString getComment();
void clear(bool _full = false); //full= false leaves the "keep this data"; full = true clears everything
void setKeep(const bool _b);
bool getKeep();
private:
QString comment;
QLineEdit *commentLineEdit;
QCheckBox *keepThisDataForNextQSOQCheckbox;
};
#endif // MAINWINDOWINPUTCOMMENT_H
klog-1.8.6/inputwidgets/mainwindowsattab.h 0000644 0001750 0001750 00000012103 14166020407 017711 0 ustar devel devel #ifndef MAINWINDOWSATTAB_H
#define MAINWINDOWSATTAB_H
/***************************************************************************
mainwindowsattab.h - description
-------------------
begin : jan 2015
copyright : (C) 2015 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
//
// This class implement the tab of the mainwindow that supports Satellites
//
#include
#include
#include "../dataproxy_sqlite.h"
#include "../locator.h"
#include "../utilities.h"
class MainWindowSatTab : public QWidget
{
Q_OBJECT
public:
explicit MainWindowSatTab(DataProxy_SQLite *dp, QWidget *parent = nullptr);
~MainWindowSatTab();
QString getSatName();
void setSatName(const QString &_t);
void setOtherSatName(const QString &_t);
void setNoSat();
QString getOtherSatName();
QString getSatMode();
double getRXFreq();
void setSatMode(const QString &_t);
bool getRepeatThis();
void setRepeatThis(const bool _t);
void addBands(QStringList _bands);
void setDefaultBands(); //Defines the default bands for SAT communications: 10m/2m/70cm/23CM only if they exist in the selected bands
void setUpLinkFreq(const double _t);
void setDownLinkFreq(const double _t);
void setLocator(const QString &_t);
void refreshData();
void setModifying (const bool _m);
void setKeep(const bool _b);
bool getKeep();
void clear(bool _full = false); //full= false leaves the "keep this data"; full = true clears everything
signals:
void setPropModeSat(const QString &_p, const bool _keep);
//void satBandTXChanged(const QString &_p);
//void satBandRXChanged(const QString &_p);
void newBandsToBeAdded(const QStringList _p);
void satTxFreqChanged(const double _p);
void satRxFreqChanged(const double _p);
void satTXFreqNeeded(const double _p);
void satRXFreqNeeded(const double _p);
void dxLocatorChanged(const QString &_p);
void returnPressed();
private slots:
void slotSatNameTextChanged();
void slotSatModeTextChanged();
void slotSatDXLocTextChanged();
void slotSatNameComboBoxChanged();
void slotSatBandRXComboBoxChanged();
void slotSatBandTXComboBoxChanged();
void slotSatFreqRXChanged(const double _f);
void slotSatFreqTXChanged(const double _f);
void slotReturnPressed();
void slotSatKeepThisDataClicked();
private:
void createUI();
void populateSatComboBox();
void setSatelliteCombo(const QString &_p);
int getSatIndex(const QString &_p);
void setBandsOfSat(const QString &_p);
void addNewBand(const QString &_p);
void setUpLink(const QString &_t);
QString bandToLetter(const QString &_band);
void autofillSatMode();
QLineEdit *satNameLineEdit;
QLineEdit *satModeLineEdit;
QLineEdit *satDXLocatorLineEdit;
QLabel *satOtherLabel;
QCheckBox *keepThisDataForNextQSOQcheckbox;
//QComboBox *satNameComboBox;
//QPushButton *satNamePushButon;
//QComboBox *satNameComboBox, *satModeComboBox;
QComboBox *satNameComboBox;
QComboBox *satBandTXComboBox, *satBandRXComboBox;
QStringList satNames, satModes;
QStringList satellitesList;
//bool txFreqBeingAutoChanged, rxFreqBeingAutoChanged, updatingBands;
bool updatingBands;
QPalette palRed, palBlack, palWhite; // To paint Text in red or black(normal)
QDoubleSpinBox *txFreqSpinBox, *rxFreqSpinBox;
DataProxy_SQLite *dataProxy;
Locator *locator;
Utilities *util;
double freqTX, freqRX;
int downLinkBandId, upLinkBandId;
QString downLinkBand, upLinkBand;
bool modifying;
bool getDarkMode();
};
#endif // MAINWINDOWSATTAB_H
klog-1.8.6/inputwidgets/mainwindowinputcomment.cpp 0000644 0001750 0001750 00000007571 14166020407 021525 0 ustar devel devel /***************************************************************************
mainwindowinputcomment.cpp - description
-------------------
begin : Ago 2016
copyright : (C) 2016 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
#include "mainwindowinputcomment.h"
MainWindowInputComment::MainWindowInputComment(QWidget *parent) :
QWidget(parent)
{
//qDebug() << "MainWindowInputComment::MainWindowInputComment" << QT_ENDL;
commentLineEdit = new QLineEdit();
keepThisDataForNextQSOQCheckbox = new QCheckBox;
comment.clear();
createUI();
//qDebug() << "MainWindowInputComment::MainWindowInputComment - END" << QT_ENDL;
}
MainWindowInputComment::~MainWindowInputComment(){}
void MainWindowInputComment::createUI()
{
QLabel *commentLabel = new QLabel(tr("Comment"));
commentLabel->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
commentLineEdit->setToolTip(tr("Add a comment for this QSO."));
QLabel *keepLabel = new QLabel();
keepLabel->setText(tr("Keep this data"));
keepLabel->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
keepLabel->setToolTip(tr("Data entered in this tab will be copied into the next QSO."));
keepThisDataForNextQSOQCheckbox->setToolTip(tr("Data entered in this tab will be copied into the next QSO."));
QGridLayout *tabLayout = new QGridLayout;
//QVBoxLayout *tabLayout = new QVBoxLayout;
//tabLayout->addWidget(commentLineEdit);
tabLayout->addWidget(commentLabel, 0, 0);
tabLayout->addWidget(commentLineEdit, 0, 1);
tabLayout->addWidget(keepLabel, 2, 1);
tabLayout->addWidget(keepThisDataForNextQSOQCheckbox, 2, 2);
//tabLayout->setSizeConstraint(QLayout::SetFixedSize);
setLayout(tabLayout);
}
void MainWindowInputComment::setData(const QString &_comment)
{
comment = _comment;
commentLineEdit->setText(comment);
}
QString MainWindowInputComment::getComment()
{
return commentLineEdit->text();
}
void MainWindowInputComment::clear(bool _full)
{
if ((!keepThisDataForNextQSOQCheckbox->isChecked()) || _full)
{
comment.clear();
commentLineEdit->clear();
}
if (_full)
{
keepThisDataForNextQSOQCheckbox->setChecked (false);
}
}
void MainWindowInputComment::setKeep(const bool _b)
{
keepThisDataForNextQSOQCheckbox->setChecked (_b);
}
bool MainWindowInputComment::getKeep()
{
return keepThisDataForNextQSOQCheckbox->isChecked ();
}
klog-1.8.6/inputwidgets/mainwindowinputothers.cpp 0000644 0001750 0001750 00000047673 14166020421 021372 0 ustar devel devel /***************************************************************************
mainwindowinputothers.cpp - description
-------------------
begin : Ago 2016
copyright : (C) 2016 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
#include "mainwindowinputothers.h"
MainWindowInputOthers::MainWindowInputOthers(DataProxy_SQLite *dp, QWidget *parent) :
QWidget(parent)
{
//qDebug() << "MainWindowInputOthers::MainWindowInputOthers" << QT_ENDL;
entitiesList.clear();
propModeList.clear();
adifValidTypes.clear();
autoUpdating = false;
dataProxy = dp;
propModeList = dataProxy->getPropModeList();
sota_ref = QString();
age = 0;
util = new Utilities;
//QLabel *entityPrimLabel, *entitySecLabel, *iotaAwardLabel, *entityNameLabel, *propModeLabel;
iotaContinentComboBox = new QComboBox();
entityPrimDivComboBox = new QComboBox();
entitySecDivComboBox = new QComboBox();
entityNameComboBox = new QComboBox();
propModeComboBox = new QComboBox();
iotaNumberLineEdit = new QLineEdit();
keepPropCheckBox = new QCheckBox();
userDefinedADIFComboBox = new QComboBox();
userDefinedADIFValueLineEdit = new QLineEdit();
// TODO: I should find the way to connect the SAT tabwidget's signal to set the propmode in this widget
// Now it is done though the mainwindow but I should avoid depending on that class for that, if possible
//connect(satTabWidget, SIGNAL(setPropModeSat(QString)), this, SLOT(slotSetPropMode(QString)) ) ;
connect(propModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotPropModeComboBoxChanged() ) ) ;
connect(userDefinedADIFComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUSerDefinedADIFComboBoxChanged() ) ) ;
connect(userDefinedADIFValueLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotSetCurrentUSerData() ) );
createUI();
setInitialADIFValues ();
//qDebug() << "MainWindowInputOthers::MainWindowInputOthers - END" << QT_ENDL;
}
MainWindowInputOthers::~MainWindowInputOthers(){}
void MainWindowInputOthers::createUI()
{
//qDebug() << "MainWindowInputOthers::createUI" << QT_ENDL;
palRed.setColor(QPalette::Text, Qt::red);
palBlack.setColor(QPalette::Text, Qt::black);
palWhite.setColor(QPalette::Text, Qt::white);
QLabel *entityPrimLabel = new QLabel(tr("Primary Div"));
QLabel *entitySecLabel = new QLabel(tr("Secondary Div"));
QLabel *iotaAwardLabel = new QLabel(tr("IOTA"));
QLabel *entityNameLabel = new QLabel(tr("Entity"));
QLabel *propModeLabel = new QLabel(tr("Propagation mode"));
QLabel *userSelectLabel = new QLabel(tr("Others"));
entityPrimLabel->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
entitySecLabel->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
iotaAwardLabel->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
entityNameLabel->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
propModeLabel->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
userSelectLabel->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
keepPropCheckBox->setText(tr("Keep propagation mode"));
entityPrimDivComboBox->setToolTip(tr("Select the primary division for this QSO."));
entitySecDivComboBox->setToolTip(tr("Select the secondary division for this QSO."));
entityNameComboBox->setToolTip(tr("Select the entity for this QSO."));
propModeComboBox->setToolTip(tr("Select the propagation mode for this QSO."));
iotaContinentComboBox->setToolTip(tr("Select the IOTA continent for this QSO."));
iotaNumberLineEdit->setToolTip(tr("Select the IOTA reference number for this QSO."));
keepPropCheckBox->setToolTip(tr("Keeps the same propagation mode for next QSO."));
userDefinedADIFComboBox->setToolTip(tr("Select the appropriate ADIF field for this QSO."));
userDefinedADIFValueLineEdit->setToolTip (tr("Value for the selected ADIF field."));
entityPrimDivComboBox->setEnabled(false);
entitySecDivComboBox->setEnabled(false);
entityNameComboBox->setEnabled(true);
propModeComboBox->setEnabled(true);
keepPropCheckBox->setEnabled(true);
QHBoxLayout *keepLayout = new QHBoxLayout;
keepLayout->addWidget(propModeComboBox);
//keepLayout->addWidget(keepPropCheckBox);
keepLayout->setSizeConstraint(QLayout::SetFixedSize);
QGridLayout *tabLayout = new QGridLayout;
tabLayout->addWidget(entityNameLabel, 0, 0);
tabLayout->addWidget(entityNameComboBox, 0, 1, 1, 2);
tabLayout->addWidget(entityPrimLabel, 1, 0);
tabLayout->addWidget(entityPrimDivComboBox, 1, 1, 1, 2);
tabLayout->addWidget(entitySecLabel, 2, 0);
tabLayout->addWidget(entitySecDivComboBox, 2, 1, 1, 2);
tabLayout->addWidget(iotaAwardLabel, 3, 0);
tabLayout->addWidget(iotaContinentComboBox, 3, 1);
tabLayout->addWidget(iotaNumberLineEdit, 3, 2);
tabLayout->addWidget(propModeLabel, 4, 0);
tabLayout->addLayout(keepLayout, 4, 1, 1, 2);
tabLayout->addWidget(entityPrimLabel, 1, 0);
tabLayout->addWidget(entityPrimDivComboBox, 1, 1, 1, 2);
tabLayout->addWidget(userSelectLabel, 5, 0);
tabLayout->addWidget(userDefinedADIFComboBox, 5, 1);
tabLayout->addWidget(userDefinedADIFValueLineEdit, 5, 2);
tabLayout->addWidget(keepPropCheckBox, 6, 2);
//tabLayout->setSizeConstraint(QLayout::SetFixedSize);
setLayout(tabLayout);
if (entitiesList.size()>1)
{
entitiesList.prepend("00-" + tr("Not Identified") + " (000)");
entityNameComboBox->addItems(entitiesList);
}
if (propModeList.size()>1)
{
propModeList.prepend("00 - " + tr("Not - Not Identified"));
propModeComboBox->addItems(propModeList);
}
iotaContinentComboBox->addItems(dataProxy->getContinentShortNames());
iotaNumberLineEdit->setInputMask("000");
iotaNumberLineEdit->setText("000");
//qDebug() << Q_FUNC_INFO << ": (" << QString::number(this->size ().width ()) << "/" << QString::number(this->size ().height ()) << ")" ;
}
void MainWindowInputOthers::clear(bool _full)
{
//qDebug() << "MainWindowInputOthers::clear" << QT_ENDL;
entityNameComboBox->setCurrentIndex(0);
userDefinedADIFComboBox->setCurrentIndex (0);
userDefinedADIFValueLineEdit->clear ();
sota_ref = QString();
age = 0;
iotaContinentComboBox->setCurrentIndex(0);
iotaNumberLineEdit->setText("000");
if ((!keepPropCheckBox->isChecked()) || _full)
{
propModeComboBox->setCurrentIndex(0);
}
if (_full)
{
keepPropCheckBox->setChecked (false);
}
}
void MainWindowInputOthers::setEntitiesList(const QStringList _qs)
{
//qDebug() << "MainWindowInputOthers::setEntitiesList: " << QString::number(_qs.length()) << QT_ENDL;
entitiesList.clear();
entitiesList << _qs;
if (entitiesList.size()>1)
{
entitiesList.prepend("00-" + tr("Not Identified") + " (000)");
//entitiesList.prepend("00-Not Identified (000)");
entityNameComboBox->addItems(entitiesList);
}
}
void MainWindowInputOthers::setEntity(const int _ent)
{// Select the appropriate entity in the ComboBox
//qDebug() << "MainWindowInputOthers::setEntity: " << QString::number(_ent) << QT_ENDL;
if (_ent<=0)
{
entityNameComboBox->setCurrentIndex(0);
return;
}
QString aux = QString();
aux = QString::number(_ent);
if (_ent > 1000)
{
aux = (QString::number(_ent)).right(3);
}
//QString pref = dataProxy->getEntityNameFromId(_ent);
//int indexC = entityNameComboBox->f
int indexC = entityNameComboBox->findText("(" + aux + ")", Qt::MatchEndsWith);
//qDebug() << "MainWindow::selectCorrectEntity: " << pref << "/" << QString::number(indexC) << QT_ENDL;
entityNameComboBox->setCurrentIndex(indexC);
setIOTAContinentFromEntity(_ent);
}
int MainWindowInputOthers::getEntity()
{
QString aux = entityNameComboBox->currentText();
if (!aux.contains ('('))
{
return -1;
}
//qDebug() << Q_FUNC_INFO << ": " << (aux.split('(').at(1).chopped(1));
//return (aux.split('(').at(1).chopped(1)).toInt ();
QString a = aux.split('(').at(1);
a.chop(1);
//qDebug() << Q_FUNC_INFO << ": " << a;
return a.toInt ();
}
QString MainWindowInputOthers::getEntityPrefix()
{
//qDebug() << "MainWindowInputOthers::getEntityPrefix: " << (entityNameComboBox->currentText()).split('-').at(0) << QT_ENDL;
return (entityNameComboBox->currentText()).split('-').at(0);
//return world->getQRZARRLId(pref);
}
void MainWindowInputOthers::setPropMode(const QString &_qs, bool _keep)
{
//qDebug() << "MainWindowInputOthers::setPropMode: " << _qs << QT_ENDL;
autoUpdating = true;
if(( propModeComboBox->findText(_qs+" -", Qt::MatchContains))>0)
{
propModeComboBox->setCurrentIndex( propModeComboBox->findText(_qs+" -", Qt::MatchContains));
keepPropCheckBox->setChecked(_keep);
}
else
{
propModeComboBox->setCurrentIndex(0);
keepPropCheckBox->setChecked(false);
}
autoUpdating = false;
}
QString MainWindowInputOthers::getPropModeFromComboBox()
{
QString _pm = QString();
//qDebug() << "MainWindow::getPropModeFromComboBox:" << propModeComboBox->currentText() << QT_ENDL;
_pm = (((propModeComboBox->currentText()).split('-')).at(1)).simplified();
QString _n = (((propModeComboBox->currentText()).split('-')).at(0)).simplified();
//qDebug() << "MainWindow::getPropModeFromComboBox: " << _pm << QT_ENDL;
if (_n == "00")
{
return QString();
}
return _pm;
}
bool MainWindowInputOthers::isSATPropagation()
{
if (getPropModeFromComboBox() == "SAT")
{
return true;
}
else
{
return false;
}
}
void MainWindowInputOthers::clearIOTA()
{
iotaContinentComboBox->setCurrentIndex(0);
iotaNumberLineEdit->setText("000");
//iotaNumberLineEdit->setPalette(palBlack);
}
bool MainWindowInputOthers::isIOTAModified()
{
if ((iotaContinentComboBox->currentIndex()>0) || (iotaNumberLineEdit->text()).toInt()>0)
{
return true;
}
else
{
return false;
}
}
void MainWindowInputOthers::setIOTA(const QString &_qs)
{//TODO: Seems to be better to send the color info like in: (it is much more flexible as I can send any color!)
//void MainWindowInputQSL::setQSLVia(const QString &_qs, QColor qColor)
//qDebug() << "MainWindow::setIOTA: " << _qs << QT_ENDL;
if ( (checkIfValidIOTA(_qs)).length() !=6 )
{
iotaNumberLineEdit->setPalette(palRed);
return;
}
else
{
QStringList values = _qs.split("-", QT_SKIP);
//qDebug() << "MainWindowInputOthers::setIOTA: IOTA " << _qs << QT_ENDL;
iotaContinentComboBox->setCurrentIndex( iotaContinentComboBox->findText(values.at(0) ) );
iotaNumberLineEdit->setText(values.at(1));
if (getDarkMode())
{
iotaNumberLineEdit->setPalette(palWhite);
}
else
{
iotaNumberLineEdit->setPalette(palBlack);
}
}
}
QString MainWindowInputOthers::getIOTA()
{
return (checkIfValidIOTA(iotaContinentComboBox->currentText() + "-" + iotaNumberLineEdit->text()));
}
void MainWindowInputOthers::setIOTAContinentFromEntity(const int _n)
{
//qDebug() << "MainWindow::setIOTAContinentFromEntity:" << QString::number(_n) << QT_ENDL;
setIOTAContinent(dataProxy->getContinentShortNameFromEntity(_n)) ;
}
void MainWindowInputOthers::setIOTAContinent(const QString &_qs)
{
//qDebug() << "MainWindowInputOthers::setIOTAContinent: " << _qs << QT_ENDL;
//qDebug() << "MainWindowInputOthers::setIOTAContinent: setting to index(a): " << QString::number(iotaContinentComboBox->findText(_qs, Qt::MatchContains)) << QT_ENDL;
if(( iotaContinentComboBox->findText(_qs, Qt::MatchContains))>0)
{
//qDebug() << "MainWindowInputOthers::setIOTAContinent: setting to index: " << QString::number(iotaContinentComboBox->findText(_qs, Qt::MatchContains)) << QT_ENDL;
iotaContinentComboBox->setCurrentIndex( iotaContinentComboBox->findText(_qs, Qt::MatchContains));
}
else
{
//qDebug() << "MainWindowInputOthers::setIOTAContinent: setting to index: 00" << QT_ENDL;
iotaContinentComboBox->setCurrentIndex(0);
}
}
QString MainWindowInputOthers::checkIfValidIOTA(const QString &_tiota)
{
/**********************************
IOTA should be always with this format: CC-NNN
being:
- CC the shortname of the continent
- NNN Number of the reference.
NNN has ALWAYS to include THREE(3) characters.
ADIF Specs says:
CC is the continent designator {NA, SA, EU , AF, OC, AS, AN}
XXX is the island designator, where 0 <= XXX ,<= 999 [use leading zeroes]
Returns a valid format IOTA if possible and "" in other cases.
************************************/
//qDebug() << "MainWindowInputOthers::checkIfValidIOTA: " << _tiota << QT_ENDL;
//bool _valid = false;
QString _continent;
QString _number;
if (_tiota.count("-") == 1)
{
QStringList _values = _tiota.split("-", QT_SKIP);
_continent = _values.at(0);
_number = _values.at(1);
}
else
{
return "";
}
//qDebug() << "MainWindowInputOthers::checkIfValidIOTA (cont) " << _continent << QT_ENDL;
//qDebug() << "MainWindowInputOthers::checkIfValidIOTA (numb): " << _number << QT_ENDL;
// Check if continent is valid
if (dataProxy->isValidContinentShortName(_continent))
{
if ( (_number.toInt() >0 ) && ((_number.toInt()) < 1000 ))
{
if ((_number.length()) == 3)
{
return _continent + "-" + _number ;
}
else if ((_number.length()) == 2)
{
return _continent + "-0" + QString::number((_number).toInt());
}
else if ((_number.length()) == 1)
{
return _continent + "-00" + QString::number((_number).toInt());
}
else
{
return "";
}
}
else
{
return "";
}
}
else
{
return QString();
}
}
void MainWindowInputOthers::slotPropModeComboBoxChanged()
{
if (autoUpdating)
{
return;
}
emit setPropMode(getPropModeFromComboBox());
}
void MainWindowInputOthers::setKeep(const bool _b)
{
keepPropCheckBox->setChecked (_b);
}
bool MainWindowInputOthers::getKeep()
{
return keepPropCheckBox->isChecked ();
}
bool MainWindowInputOthers::setUserADIFTypeComboBox(const QString &_value)
{
if (_value == "SOTA_REF")
{
userDefinedADIFComboBox->setCurrentIndex (0);
}
else if (_value == "AGE")
{
userDefinedADIFComboBox->setCurrentIndex (1);
}
else
{
return false;
}
return true;
}
QString MainWindowInputOthers::getUserADIFTypeComboBox()
{
int value = (((userDefinedADIFComboBox->currentText ()).split('-')).at(0)).toInt ();
//qDebug() << Q_FUNC_INFO << ": " << QString::number(value);
//qDebug() << Q_FUNC_INFO << ": " << QString::number(value);
switch (value)
{
case 1:
return "SOTA_REF";
case 2:
return "AGE";
case 3:
return "VUCC_GRIDS";
default:
return QString();
}
}
bool MainWindowInputOthers::setUserADIFValue(const QString &_adifValue)
{
userDefinedADIFValueLineEdit->setText (_adifValue);
return true;
}
QString MainWindowInputOthers::getUserADIFValue()
{
return userDefinedADIFValueLineEdit->text();
}
bool MainWindowInputOthers::setInitialADIFValues()
{
adifValidTypes << "01-" + tr("SOTA Ref") << "02-" + tr ("Age") << "03-" + tr ("VUCC grids");
userDefinedADIFComboBox->clear ();
userDefinedADIFComboBox->addItems (adifValidTypes);
return true;
}
void MainWindowInputOthers::slotUSerDefinedADIFComboBoxChanged()
{
//qDebug() << Q_FUNC_INFO << ": " << getUserADIFTypeComboBox ();
QString currentTag = getUserADIFTypeComboBox ();
setColorsForUserDefinedADIFValueLineEdit();
if (currentTag == "SOTA_REF")
{
userDefinedADIFValueLineEdit->setText (sota_ref);
}
else if (currentTag == "AGE")
{
userDefinedADIFValueLineEdit->setText (QString::number(age));
}
else if (currentTag == "VUCC_GRIDS")
{
userDefinedADIFValueLineEdit->setText (vucc_grids);
}
}
bool MainWindowInputOthers::setVUCCGrids(const QString &_op)
{
//qDebug() << Q_FUNC_INFO << ": " << _op;
if (checkVUCC_GRIDS(_op))
{
vucc_grids = _op;
slotUSerDefinedADIFComboBoxChanged();
return true;
}
return false;
}
bool MainWindowInputOthers::checkVUCC_GRIDS(const QString &_string)
{
//qDebug() << Q_FUNC_INFO << ": " << _string;
if (util->isValidVUCCGrids (_string))
{
setColorsForUserDefinedADIFValueLineEdit();
return true;
}
else
{
userDefinedADIFValueLineEdit->setPalette (palRed);
return false;
}
}
QString MainWindowInputOthers::getVUCCGrids()
{
if (checkVUCC_GRIDS (vucc_grids))
{
return vucc_grids;
}
else
{
return QString();
}
}
void MainWindowInputOthers::setColorsForUserDefinedADIFValueLineEdit()
{
if (getDarkMode())
{
userDefinedADIFValueLineEdit->setPalette(palWhite);
}
else
{
userDefinedADIFValueLineEdit->setPalette(palBlack);
}
}
bool MainWindowInputOthers::setSOTA(const QString &_op)
{
//qDebug() << Q_FUNC_INFO << ": " << _op;
sota_ref = _op;
slotUSerDefinedADIFComboBoxChanged();
return true;
}
QString MainWindowInputOthers::getSOTA()
{
//qDebug() << Q_FUNC_INFO;
return sota_ref;
}
bool MainWindowInputOthers::setAge(const double _op)
{
//qDebug() << Q_FUNC_INFO << ": " << _op;
age = _op;
slotUSerDefinedADIFComboBoxChanged();
return true;
}
double MainWindowInputOthers::getAge()
{
return age;
}
void MainWindowInputOthers::slotSetCurrentUSerData()
{
QString currentTag = getUserADIFTypeComboBox ();
if (currentTag == "SOTA_REF")
{
sota_ref = userDefinedADIFValueLineEdit->text();
}
else if (currentTag == "AGE")
{
age = userDefinedADIFValueLineEdit->text().toDouble();
}
else if (currentTag == "VUCC_GRIDS")
{
//if (checkVUCC_GRIDS(userDefinedADIFValueLineEdit->text()))
//{}
vucc_grids = userDefinedADIFValueLineEdit->text().toUpper();
userDefinedADIFValueLineEdit->setText (vucc_grids);
}
}
bool MainWindowInputOthers::getDarkMode()
{
if ( iotaNumberLineEdit->palette().color (QPalette::Base) == "#646464")
{
return true;
}
else
{
return false;
}
}
klog-1.8.6/inputwidgets/mainwindowinputeqsl.cpp 0000644 0001750 0001750 00000054532 14166020407 021026 0 ustar devel devel /***************************************************************************
mainwindowinputeqsl.cpp - description
-------------------
begin : jun 2017
copyright : (C) 2017 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
#include "mainwindowinputeqsl.h"
MainWindowInputEQSL::MainWindowInputEQSL(DataProxy_SQLite *dp, QWidget *parent) :
QWidget(parent)
{
//qDebug() << "MainWindowInputEQSL::MainWindowInputEQSL" << QT_ENDL;
util = new Utilities;
dataProxy = dp;
eqslSentComboBox = new QComboBox;
eqslRecComboBox = new QComboBox;
lotwSentComboBox = new QComboBox;
lotwRecComboBox = new QComboBox;
clublogComboBox = new QComboBox;
qrzcomComboBox = new QComboBox;
eqslSentQDateEdit = new QDateEdit;
eqslRecQDateEdit = new QDateEdit;
lotwSentQDateEdit = new QDateEdit;
lotwRecQDateEdit = new QDateEdit;
clublogQDateEdit = new QDateEdit;
qrzcomQDateEdit = new QDateEdit;
createUI();
setDefaultData();
clear();
//qDebug() << "MainWindowInputEQSL::MainWindowInputEQSL - END" << QT_ENDL;
}
void MainWindowInputEQSL::createUI()
{
qslSentStatusList.clear();
qslRcvdStatusList.clear();
clubLogStatusList.clear();
qslSentStatusList = dataProxy->getQSLSentList();
qslRcvdStatusList = dataProxy->getQSLRcvdList();
clubLogStatusList = dataProxy->getClubLogStatusList();
eqslSentQDateEdit->setDisplayFormat("dd/MM/yyyy");
eqslRecQDateEdit->setDisplayFormat("dd/MM/yyyy");
lotwSentQDateEdit->setDisplayFormat("dd/MM/yyyy");
lotwRecQDateEdit->setDisplayFormat("dd/MM/yyyy");
clublogQDateEdit->setDisplayFormat("dd/MM/yyyy");
qrzcomQDateEdit->setDisplayFormat("dd/MM/yyyy");
clublogQDateEdit->setToolTip(tr("Date of the ClubLog upload."));
qrzcomQDateEdit->setToolTip(tr("Date of the QRZ.com upload."));
eqslSentQDateEdit->setToolTip(tr("Date of the eQSL sending."));
eqslRecQDateEdit->setToolTip(tr("Date of the eQSL reception."));
lotwSentQDateEdit->setToolTip(tr("Date of the LoTW sending."));
lotwRecQDateEdit->setToolTip(tr("Date of the LoTW reception."));
clublogComboBox->setToolTip(tr("Status on ClubLog."));
qrzcomComboBox->setToolTip(tr("Status on QRZ.com."));
eqslSentComboBox->setToolTip(tr("Status of the eQSL sending."));
eqslRecComboBox->setToolTip(tr("Status of the eQSL reception."));
lotwSentComboBox->setToolTip(tr("Status of the LoTW sending."));
lotwRecComboBox->setToolTip(tr("Status of the LoTW reception."));
// eQSL Tab definition starts here
QLabel *clublogLabelN = new QLabel(tr("ClubLog"));
clublogLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QLabel *qrzcomLabelN = new QLabel(tr("QRZ.com"));
qrzcomLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QLabel *eQSLSentLabelN = new QLabel(tr("eQSL Sent"));
eQSLSentLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QLabel *eQSLRecLabelN = new QLabel(tr("eQSL Rec"));
eQSLRecLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QLabel *lotWSentLabelN = new QLabel(tr("LoTW Sent"));
lotWSentLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QLabel *lotWRecLabelN = new QLabel(tr("LoTW Rec"));
lotWRecLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QGridLayout *eqslInputTabWidgetLayout = new QGridLayout;
eqslInputTabWidgetLayout->addWidget(clublogLabelN, 0, 0);
eqslInputTabWidgetLayout->addWidget(eQSLSentLabelN, 1, 0);
eqslInputTabWidgetLayout->addWidget(eQSLRecLabelN, 2, 0);
eqslInputTabWidgetLayout->addWidget(lotWSentLabelN, 3, 0);
eqslInputTabWidgetLayout->addWidget(lotWRecLabelN, 4, 0);
eqslInputTabWidgetLayout->addWidget(qrzcomLabelN, 5, 0);
eqslInputTabWidgetLayout->addWidget(clublogComboBox, 0, 1);
eqslInputTabWidgetLayout->addWidget(eqslSentComboBox, 1, 1);
eqslInputTabWidgetLayout->addWidget(eqslRecComboBox, 2, 1);
eqslInputTabWidgetLayout->addWidget(lotwSentComboBox, 3, 1);
eqslInputTabWidgetLayout->addWidget(lotwRecComboBox, 4, 1);
eqslInputTabWidgetLayout->addWidget(qrzcomComboBox, 5, 1);
eqslInputTabWidgetLayout->addWidget(clublogQDateEdit, 0, 2);
eqslInputTabWidgetLayout->addWidget(eqslSentQDateEdit, 1, 2);
eqslInputTabWidgetLayout->addWidget(eqslRecQDateEdit, 2, 2);
eqslInputTabWidgetLayout->addWidget(lotwSentQDateEdit, 3, 2);
eqslInputTabWidgetLayout->addWidget(lotwRecQDateEdit, 4, 2);
eqslInputTabWidgetLayout->addWidget(qrzcomQDateEdit, 5, 2);
//eqslInputTabWidgetLayout->setSizeConstraint(QLayout::SetFixedSize);
setLayout(eqslInputTabWidgetLayout);
connect(clublogComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotClubLogComboBoxChanged() ) ) ;
connect(eqslSentComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(sloteQSLSentComboBoxChanged() ) ) ;
connect(eqslRecComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(sloteQSLRecvComboBoxChanged() ) ) ;
connect(lotwSentComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotLotwSentComboBoxChanged() ) ) ;
connect(lotwRecComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotLotwRecvComboBoxChanged() ) ) ;
connect(qrzcomComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotQRZCOMComboBoxChanged() ) ) ;
}
void MainWindowInputEQSL::setDefaultData()
{
//qsAux << tr("Y-Yes") << tr("N-No") << tr("R-Requested") << tr("I-Ignore") << tr("V-Validated");
//eqslRecComboBox->addItems(qsAux);
//lotwRecComboBox->addItems(qsAux);
eqslRecComboBox->addItems(qslRcvdStatusList);
lotwRecComboBox->addItems(qslRcvdStatusList);
//qsAux.clear();
//qsAux << tr("Y-Yes") << tr("N-No") << tr("R-Requested") << tr("Q-Queued") << tr("I-Ignore");
//eqslSentComboBox->addItems(qsAux);
//lotwSentComboBox->addItems(qsAux);
eqslSentComboBox->addItems(qslSentStatusList);
lotwSentComboBox->addItems(qslSentStatusList);
//QStringList qsAux;
//qsAux.clear();
//qsAux << tr("Y-Uploaded") << tr("N-Do not upload") << tr("M-Modified");
clublogComboBox->addItems(clubLogStatusList);
qrzcomComboBox->addItems(clubLogStatusList);
queueSentByDefault = true;
}
void MainWindowInputEQSL::clear()
{
//qDebug() << "MainWindowInputEQSL::clear" << QT_ENDL;
// Do not upload
if (queueSentByDefault)
{
clublogComboBox->setCurrentIndex( clublogComboBox->findText("M", Qt::MatchStartsWith));
eqslSentComboBox->setCurrentIndex( eqslSentComboBox->findText("Q", Qt::MatchStartsWith));
lotwSentComboBox->setCurrentIndex( lotwSentComboBox->findText("Q", Qt::MatchStartsWith));
qrzcomComboBox->setCurrentIndex( qrzcomComboBox->findText("M", Qt::MatchStartsWith));
}
else
{
clublogComboBox->setCurrentIndex( clublogComboBox->findText("N", Qt::MatchStartsWith));
qrzcomComboBox->setCurrentIndex( qrzcomComboBox->findText("N", Qt::MatchStartsWith));
eqslSentComboBox->setCurrentIndex( eqslSentComboBox->findText("N", Qt::MatchStartsWith));
lotwSentComboBox->setCurrentIndex( lotwSentComboBox->findText("N", Qt::MatchStartsWith));
}
eqslRecComboBox->setCurrentIndex(eqslRecComboBox->findText("N", Qt::MatchStartsWith));
lotwRecComboBox->setCurrentIndex(lotwRecComboBox->findText("N", Qt::MatchStartsWith));
eqslSentQDateEdit->setDate(util->getDefaultDate());
eqslRecQDateEdit->setDate(util->getDefaultDate());
lotwSentQDateEdit->setDate(util->getDefaultDate());
lotwRecQDateEdit->setDate(util->getDefaultDate());
clublogQDateEdit->setDate(util->getDefaultDate());
qrzcomQDateEdit->setDate(util->getDefaultDate());
}
QString MainWindowInputEQSL::getClubLogStatus()
{
QString _pm = QString();
//qDebug() << "MainWindowInputEQSL::getClubLogStatus:" << clublogComboBox->currentText() << QT_ENDL;
_pm = (((clublogComboBox->currentText()).split('-')).at(0)).simplified();
return _pm;
}
QString MainWindowInputEQSL::getQRZCOMStatus()
{
QString _pm = QString();
_pm = (((qrzcomComboBox->currentText()).split('-')).at(0)).simplified();
return _pm;
}
QString MainWindowInputEQSL::getEQSLRecStatus()
{
QString _pm = QString();
//qDebug() << "MainWindowInputEQSL::getEQSLRecStatus:" << eqslRecComboBox->currentText() << QT_ENDL;
_pm = (((eqslRecComboBox->currentText()).split('-')).at(0)).simplified();
//qDebug() << "MainWindowInputEQSL::getEQSLRecStatus: " << _pm << QT_ENDL;
//if (_pm == "Not")
//{
// return QString();
//}
return _pm;
}
QString MainWindowInputEQSL::getEQSLSenStatus()
{
QString _pm = QString();
//qDebug() << "MainWindowInputEQSL::getEQSLSenStatus:" << eqslSentComboBox->currentText() << QT_ENDL;
_pm = (((eqslSentComboBox->currentText()).split('-')).at(0)).simplified();
//qDebug() << "MainWindowInputEQSL::getEQSLSenStatus: " << _pm << QT_ENDL;
//if (_pm == "Not")
//{
// return QString();
//}
return _pm;
}
QString MainWindowInputEQSL::getLOTWRecStatus()
{
QString _pm = QString();
//qDebug() << "MainWindowInputEQSL::getLOTWRecStatus:" << lotwRecComboBox->currentText() << QT_ENDL;
_pm = (((lotwRecComboBox->currentText()).split('-')).at(0)).simplified();
//qDebug() << "MainWindowInputEQSL::getLOTWRecStatus: " << _pm << QT_ENDL;
//if (_pm == "Not")
//{
// return QString();
//}
return _pm;
}
QString MainWindowInputEQSL::getLOTWSenStatus()
{
QString _pm = QString();
//qDebug() << "MainWindowInputEQSL::getLOTWSenStatus:" << lotwSentComboBox->currentText() << QT_ENDL;
_pm = (((lotwSentComboBox->currentText()).split('-')).at(0)).simplified();
//qDebug() << "MainWindowInputEQSL::getLOTWSenStatus: " << _pm << QT_ENDL;
//if (_pm == "Not")
//{
// return QString();
//}
return _pm;
}
void MainWindowInputEQSL::setClubLogStatus(const QString &_qs)
{
//qDebug() << "MainWindowInputEQSL::setClubLogStatus: " << _qs << QT_ENDL;
if((( clublogComboBox->findText(_qs, Qt::MatchStartsWith))>=0) && (_qs.length()>0) )
{
clublogComboBox->setCurrentIndex( clublogComboBox->findText(_qs+" -", Qt::MatchStartsWith));
}
else
{
clublogComboBox->setCurrentIndex( clublogComboBox->findText("N", Qt::MatchStartsWith));
}
}
void MainWindowInputEQSL::setQRZCOMStatus(const QString &_qs)
{
//qDebug() << "MainWindowInputEQSL::setClubLogStatus: " << _qs << QT_ENDL;
if((( qrzcomComboBox->findText(_qs, Qt::MatchStartsWith))>=0) && (_qs.length()>0) )
{
qrzcomComboBox->setCurrentIndex( qrzcomComboBox->findText(_qs+" -", Qt::MatchStartsWith));
}
else
{
qrzcomComboBox->setCurrentIndex( qrzcomComboBox->findText("N", Qt::MatchStartsWith));
}
}
void MainWindowInputEQSL::setEQSLRecStatus(const QString &_qs)
{
//qDebug() << "MainWindowInputEQSL::setEQSLRecStatus: " << _qs << QT_ENDL;
//if(( eqslRecComboBox->findText(_qs+" -", Qt::MatchStartsWith))>=0)
if((( eqslRecComboBox->findText(_qs, Qt::MatchStartsWith))>=0) && (_qs.length()>0) )
{
eqslRecComboBox->setCurrentIndex( eqslRecComboBox->findText(_qs+" -", Qt::MatchStartsWith));
}
else
{
eqslRecComboBox->setCurrentIndex( eqslRecComboBox->findText("N", Qt::MatchStartsWith));
}
}
void MainWindowInputEQSL::setEQSLSenStatus(const QString &_qs)
{
//qDebug() << "MainWindowInputEQSL::setEQSLSenStatus: #" << _qs+" -" << QT_ENDL;
if((( eqslSentComboBox->findText(_qs, Qt::MatchStartsWith))>=0) && (_qs.length()>0) )
{
//qDebug() << "MainWindowInputEQSL::setEQSLSenStatus: found: " << _qs << " - Index: " << QString::number(eqslSentComboBox->findText(_qs, Qt::MatchStartsWith)) << QT_ENDL;
eqslSentComboBox->setCurrentIndex( eqslSentComboBox->findText(_qs, Qt::MatchStartsWith));
}
else
{
//qDebug() << "MainWindowInputEQSL::setEQSLSenStatus: NOT found" << QT_ENDL;
if (queueSentByDefault)
{
//qDebug() << "MainWindowInputEQSL::setEQSLSenStatus: NOT found - Q is defined by default" << QT_ENDL;
eqslSentComboBox->setCurrentIndex( eqslSentComboBox->findText("Q", Qt::MatchStartsWith));
}
else
{
//qDebug() << "MainWindowInputEQSL::setEQSLSenStatus: NOT found - Q is NOT defined by default" << QT_ENDL;
eqslSentComboBox->setCurrentIndex( eqslSentComboBox->findText("N", Qt::MatchStartsWith));
eqslSentComboBox->setCurrentIndex(1);
}
//qDebug() << "MainWindowInputEQSL::setEQSLSenStatus: NOT found" << QT_ENDL;
//eqslSentComboBox->setCurrentIndex(1);
}
//qDebug() << "MainWindowInputEQSL::setEQSLSenStatus - END" << QT_ENDL;
}
void MainWindowInputEQSL::setLOTWRecStatus(const QString &_qs)
{
//qDebug() << "MainWindowInputEQSL::setLOTWRecStatus: " << _qs << QT_ENDL;
if((( lotwRecComboBox->findText(_qs, Qt::MatchStartsWith))>=0) && (_qs.length()>0) )
//if(( lotwRecComboBox->findText(_qs+" -", Qt::MatchStartsWith))>=0)
{
lotwRecComboBox->setCurrentIndex( lotwRecComboBox->findText(_qs+" -", Qt::MatchStartsWith));
}
else
{
lotwRecComboBox->setCurrentIndex(lotwRecComboBox->findText("N", Qt::MatchStartsWith));
}
}
void MainWindowInputEQSL::setLOTWSenStatus(const QString &_qs)
{
//qDebug() << "MainWindowInputEQSL::setLOTWSenStatus: " << _qs << QT_ENDL;
if((( lotwSentComboBox->findText(_qs, Qt::MatchStartsWith))>=0) && (_qs.length()>0) )
//if(( lotwSentComboBox->findText(_qs+" -", Qt::MatchStartsWith))>=0)
{
lotwSentComboBox->setCurrentIndex( lotwSentComboBox->findText(_qs+" -", Qt::MatchStartsWith));
}
else
{
if (queueSentByDefault)
{
lotwSentComboBox->setCurrentIndex( lotwSentComboBox->findText("Q", Qt::MatchStartsWith));
}
else
{
lotwSentComboBox->setCurrentIndex( lotwSentComboBox->findText("N", Qt::MatchStartsWith));
}
//lotwSentComboBox->setCurrentIndex(1);
}
}
void MainWindowInputEQSL::slotLotwRecvComboBoxChanged(){
//qDebug() << "MainWindowInputEQSL::slotLotwRecvComboBoxChanged" << QT_ENDL;
//QSLRDATE (only valid if QSL_RCVD is Y-0, I-3, or V-4)
//Y-Yes-0
//N-No-1
//R-Requested-2
//I-Ignore-3
//V-Verified-4
int i = lotwRecComboBox->currentIndex();
switch (i)
{
case 0:
lotwRecQDateEdit->setEnabled(true);
lotwRecQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
case 2:
lotwRecQDateEdit->setEnabled(true);
lotwRecQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
case 3:
lotwRecQDateEdit->setEnabled(true);
break;
case 4:
lotwRecQDateEdit->setEnabled(true);
break;
default: //NO
lotwRecQDateEdit->setEnabled(false);
break;
}
}
void MainWindowInputEQSL::slotLotwSentComboBoxChanged(){
//qDebug() << "MainWindowInputEQSL::slotLotwSentComboBoxChanged" << QT_ENDL;
int i = lotwSentComboBox->currentIndex();
//{Y, N, R, I, V}
//(QSLSDATE is only valid if QSL_SENT is Y-0, Q-3, or I-4)
// Y-Yes = 0
// N-No = 1
// R-Requested = 2
// Q-Queued = 3
// I-Ignore = 4
switch (i)
{
case 0:
lotwSentQDateEdit->setEnabled(true);
lotwSentQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
case 2:
lotwSentQDateEdit->setEnabled(true);
lotwSentQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
case 3:
lotwSentQDateEdit->setEnabled(true);
lotwSentQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
case 4:
lotwSentQDateEdit->setEnabled(true);
lotwSentQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
default: //NO
lotwSentQDateEdit->setEnabled(false);
break;
}
}
void MainWindowInputEQSL::sloteQSLRecvComboBoxChanged(){
//qDebug() << "MainWindowInputEQSL::sloteQSLRecvComboBoxChanged" << QT_ENDL;
//QSLRDATE (only valid if QSL_RCVD is Y-0, I-3, or V-4)
//Y-Yes-0
//N-No-1
//R-Requested-2
//I-Ignore-3
//V-Verified-4
int i = eqslRecComboBox->currentIndex();
switch (i)
{
case 0:
eqslRecQDateEdit->setEnabled(true);
eqslRecQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
case 2:
eqslRecQDateEdit->setEnabled(true);
eqslRecQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
case 3:
eqslRecQDateEdit->setEnabled(true);
eqslRecQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
case 4:
eqslRecQDateEdit->setEnabled(true);
eqslRecQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
default: //NO
eqslRecQDateEdit->setEnabled(false);
break;
}
}
void MainWindowInputEQSL::sloteQSLSentComboBoxChanged(){
//qDebug() << "MainWindowInputEQSL::sloteQSLSentComboBoxChanged" << QT_ENDL;
int i = eqslSentComboBox->currentIndex();
//{Y, N, R, I, V}
//(QSLSDATE is only valid if QSL_SENT is Y-0, Q-3, or I-4)
// Y-Yes = 0
// N-No = 1
// R-Requested = 2
// Q-Queued = 3
// I-Ignore = 4
switch (i)
{
case 0:
eqslSentQDateEdit->setEnabled(true);
eqslSentQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
case 2:
eqslSentQDateEdit->setEnabled(true);
eqslSentQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
case 3:
eqslSentQDateEdit->setEnabled(true);
eqslSentQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
case 4:
eqslSentQDateEdit->setEnabled(true);
eqslSentQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
default: //NO
eqslSentQDateEdit->setEnabled(false);
break;
}
}
void MainWindowInputEQSL::slotClubLogComboBoxChanged()
{
int i = clublogComboBox->currentIndex();
//{Y, N, M}
// Y-Yes = 0
// N-No = 1
// M-Modified = 2
switch (i)
{
case 0:
clublogQDateEdit->setEnabled(true);
clublogQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
case 2:
clublogQDateEdit->setEnabled(true);
clublogQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
default: //NO
clublogQDateEdit->setEnabled(false);
break;
}
}
void MainWindowInputEQSL::setClubLogDate(const QDate _qs)
{
if (_qs.isValid())
{
clublogQDateEdit->setDate(_qs);
}
else
{
clublogQDateEdit->clear();
}
}
void MainWindowInputEQSL::slotQRZCOMComboBoxChanged()
{
int i = qrzcomComboBox->currentIndex();
//{Y, N, M}
// Y-Yes = 0
// N-No = 1
// M-Modified = 2
switch (i)
{
case 0:
qrzcomQDateEdit->setEnabled(true);
qrzcomQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
case 2:
qrzcomQDateEdit->setEnabled(true);
qrzcomQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
default: //NO
qrzcomQDateEdit->setEnabled(false);
break;
}
}
void MainWindowInputEQSL::setQRZCOMDate(const QDate _qs)
{
if (_qs.isValid())
{
qrzcomQDateEdit->setDate(_qs);
}
else
{
qrzcomQDateEdit->clear();
}
}
void MainWindowInputEQSL::setEQSLRecDate(const QDate _qs)
{
if (_qs.isValid())
{
eqslRecQDateEdit->setDate(_qs);
}
else
{
eqslRecQDateEdit->clear();
}
}
void MainWindowInputEQSL::setEQSLSenDate(const QDate _qs)
{
if (_qs.isValid())
{
eqslSentQDateEdit->setDate(_qs);
}
else
{
eqslSentQDateEdit->clear();
}
}
void MainWindowInputEQSL::setLOTWRecDate(const QDate _qs)
{
if (_qs.isValid())
{
lotwRecQDateEdit->setDate(_qs);
}
else
{
lotwRecQDateEdit->clear();
}
}
void MainWindowInputEQSL::setLOTWSenDate(const QDate _qs)
{
if (_qs.isValid())
{
lotwSentQDateEdit->setDate(_qs);
}
else
{
lotwSentQDateEdit->clear();
}
}
QDate MainWindowInputEQSL::getClubLogDate()
{
return clublogQDateEdit->date();
}
QDate MainWindowInputEQSL::getQRZCOMDate()
{
return qrzcomQDateEdit->date();
}
QDate MainWindowInputEQSL::getEQSLRecDate()
{
return eqslRecQDateEdit->date();
}
QDate MainWindowInputEQSL::getEQSLSenDate()
{
return eqslSentQDateEdit->date();
}
QDate MainWindowInputEQSL::getLOTWRecDate()
{
return lotwRecQDateEdit->date();
}
QDate MainWindowInputEQSL::getLOTWSenDate()
{
return lotwSentQDateEdit->date();
}
void MainWindowInputEQSL::setQueueSentByDefault(const bool _b)
{
queueSentByDefault = _b;
}
klog-1.8.6/inputwidgets/mainwindowinputothers.h 0000644 0001750 0001750 00000010651 14166020407 021025 0 ustar devel devel #ifndef MAINWINDOWINPUTOTHERS_H
#define MAINWINDOWINPUTOTHERS_H
/***************************************************************************
mainwindowminputothers.h - description
-------------------
begin : ago 2016
copyright : (C) 2016 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
//
// This class implement the tab of the mainwindow that supports the Others tab
//
#include
#include
#include "../dataproxy_sqlite.h"
#include "../utilities.h"
#include "../klogdefinitions.h"
class MainWindowInputOthers : public QWidget
{
Q_OBJECT
public:
MainWindowInputOthers(DataProxy_SQLite *dp, QWidget *parent = nullptr);
~MainWindowInputOthers();
void setEntitiesList(const QStringList _qs);
void setEntity(const int _n);
int getEntity();
QString getEntityPrefix();
void setPropMode(const QString &_qs, bool _keep);
QString getPropModeFromComboBox();
bool isSATPropagation();
bool setUserADIFTypeComboBox(const QString &_value);
QString getUserADIFTypeComboBox();
bool setUserADIFValue(const QString &_adifValue);
QString getUserADIFValue();
bool setSOTA(const QString &_op);
QString getSOTA();
bool setAge(const double _op);
double getAge();
bool setVUCCGrids(const QString &_op);
QString getVUCCGrids();
void setIOTA(const QString &_qs);
QString getIOTA();
void setIOTAContinentFromEntity(const int _n);
void setIOTAContinent(const QString &_qs);
bool isIOTAModified();
void clearIOTA();
void setKeep(const bool _b);
bool getKeep();
void createUI();
void clear(bool _full = false); //full= false leaves the "keep this data"; full = true clears everything
signals:
void setPropMode(const QString _p);
private slots:
//void slotSetPropMode(const QString &_p); // To receive the signal from the SAT widget and set "SAT" propagation mode, of needed.
void slotPropModeComboBoxChanged();
void slotUSerDefinedADIFComboBoxChanged();
void slotSetCurrentUSerData();
private:
QString checkIfValidIOTA(const QString &_tiota); //TODO: There is an equivalent function in the Awards class. I should use only one!
void setColorsForUserDefinedADIFValueLineEdit();
bool checkVUCC_GRIDS(const QString &_string);
bool setInitialADIFValues();
bool getDarkMode();
Utilities *util;
DataProxy_SQLite *dataProxy;
QStringList entitiesList, propModeList;
//QLabel *entityPrimLabel, *entitySecLabel, *iotaAwardLabel, *entityNameLabel, *propModeLabel;
QComboBox *iotaContinentComboBox, *entityPrimDivComboBox, *entitySecDivComboBox, *entityNameComboBox, *propModeComboBox;
QLineEdit *iotaNumberLineEdit;
QCheckBox *keepPropCheckBox;
QPalette palRed, palBlack, palWhite;
bool autoUpdating;
QComboBox *userDefinedADIFComboBox;
QLineEdit *userDefinedADIFValueLineEdit;
QStringList adifValidTypes;
QString sota_ref, vucc_grids;
double age;
};
#endif // MAINWINDOWINPUTOTHERS_H
klog-1.8.6/inputwidgets/mainwindowinputeqsl.h 0000644 0001750 0001750 00000007634 14166020407 020474 0 ustar devel devel #ifndef MAINWINDOWINPUTEQSL_H
#define MAINWINDOWINPUTEQSL_H
/***************************************************************************
mainwindowinputeqsl.h - description
-------------------
begin : jun 2017
copyright : (C) 2017 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
//
// This class implement the tab of the mainwindow that supports the eQSL options
//
#include
#include
#include
#include "../dataproxy_sqlite.h"
#include "../utilities.h"
class MainWindowInputEQSL : public QWidget
{
Q_OBJECT
public:
explicit MainWindowInputEQSL(DataProxy_SQLite *dp, QWidget *parent = nullptr);
//~MainWindowInputEQSL();
//void setData(const QString &_comment);
//QString getComment();
void clear();
QString getQRZCOMStatus();
QString getClubLogStatus();
QString getEQSLRecStatus();
QString getEQSLSenStatus();
QString getLOTWRecStatus();
QString getLOTWSenStatus();
void setQRZCOMStatus(const QString &_qs);
void setClubLogStatus(const QString &_qs);
void setEQSLRecStatus(const QString &_qs);
void setEQSLSenStatus(const QString &_qs);
void setLOTWRecStatus(const QString &_qs);
void setLOTWSenStatus(const QString &_qs);
QDate getQRZCOMDate();
QDate getClubLogDate();
QDate getEQSLRecDate();
QDate getEQSLSenDate();
QDate getLOTWRecDate();
QDate getLOTWSenDate();
void setQRZCOMDate(const QDate _qs);
void setClubLogDate(const QDate _qs);
void setEQSLRecDate(const QDate _qs);
void setEQSLSenDate(const QDate _qs);
void setLOTWRecDate(const QDate _qs);
void setLOTWSenDate(const QDate _qs);
void setQueueSentByDefault(const bool _b);
signals:
private slots:
void slotQRZCOMComboBoxChanged();
void slotClubLogComboBoxChanged();
void sloteQSLRecvComboBoxChanged();
void sloteQSLSentComboBoxChanged();
void slotLotwRecvComboBoxChanged();
void slotLotwSentComboBoxChanged();
private:
void createUI();
void setDefaultData();
QComboBox *eqslSentComboBox, *eqslRecComboBox, *lotwSentComboBox, *lotwRecComboBox, *clublogComboBox, *qrzcomComboBox;
QDateEdit *eqslSentQDateEdit, *eqslRecQDateEdit, *lotwSentQDateEdit, *lotwRecQDateEdit, *clublogQDateEdit, *qrzcomQDateEdit;
DataProxy_SQLite *dataProxy;
Utilities *util;
QStringList qslSentStatusList, qslRcvdStatusList, clubLogStatusList;
bool queueSentByDefault;
};
#endif // MAINWINDOWINPUTEQSL_H
klog-1.8.6/inputwidgets/mainwindowinputqsl.cpp 0000644 0001750 0001750 00000026005 14166020407 020653 0 ustar devel devel /***************************************************************************
mainwindowinputqsl.cpp - description
-------------------
begin : jun 2017
copyright : (C) 2017 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
//
// This class implement the tab of the mainwindow that supports the QSL options
//
#include "mainwindowinputqsl.h"
MainWindowInputQSL::MainWindowInputQSL(DataProxy_SQLite *dp, QWidget *parent) :
QWidget(parent)
{
//qDebug() << "MainWindowInputQSL::MainWindowInputQSL" << QT_ENDL;
util = new Utilities;
qslSentComboBox = new QComboBox;
qslRecComboBox = new QComboBox;
qslSentViaComboBox = new QComboBox;
qslRecViaComboBox = new QComboBox;
qslSentQDateEdit = new QDateEdit;
qslRecQDateEdit = new QDateEdit;
qslViaLineEdit = new QLineEdit;
qslmsgTextEdit = new QTextEdit;
dataProxy = dp;
createUI();
setDefaultData();
clear();
//qDebug() << "MainWindowInputQSL::MainWindowInputQSL - END" << QT_ENDL;
}
MainWindowInputQSL::~MainWindowInputQSL(){}
void MainWindowInputQSL::createUI()
{
// QSL Tab definition starts here
qslSentQDateEdit->setDisplayFormat("dd/MM/yyyy");
qslRecQDateEdit->setDisplayFormat("dd/MM/yyyy");
QLabel *QSLSentLabelN = new QLabel(tr("QSL Sent"));
QSLSentLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QLabel *QSLRecLabelN = new QLabel(tr("QSL Rec"));
QSLRecLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QLabel *QSLViaLabelN = new QLabel(tr("QSL Via"));
QSLViaLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QLabel *QSLMsgLabelN = new QLabel(tr("QSL Msg"));
QSLMsgLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
qslSentComboBox->setToolTip(tr("Status of the QSL sending."));
qslRecComboBox->setToolTip(tr("Status of the QSL reception."));
qslSentViaComboBox->setToolTip(tr("QSL sending information."));
qslRecViaComboBox->setToolTip(tr("QSL reception information."));
qslSentQDateEdit->setToolTip(tr("Date of the QSL sending."));
qslRecQDateEdit->setToolTip(tr("Date of the QSL reception."));
qslmsgTextEdit->setToolTip(tr("Message of the QSL."));
qslViaLineEdit->setToolTip(tr("QSL via information."));
QGridLayout *QSLLayout = new QGridLayout;
QSLLayout->addWidget(QSLSentLabelN, 0, 0);
QSLLayout->addWidget(QSLRecLabelN, 1, 0);
QSLLayout->addWidget(QSLViaLabelN, 2, 0);
QSLLayout->addWidget(QSLMsgLabelN, 3, 0);
QSLLayout->addWidget(qslSentComboBox, 0, 1);
QSLLayout->addWidget(qslRecComboBox, 1, 1);
QSLLayout->addWidget(qslViaLineEdit, 2, 1, 1, -1);
QSLLayout->addWidget(qslmsgTextEdit, 3, 1, 1, -1);
QSLLayout->addWidget(qslSentQDateEdit, 0, 2);
QSLLayout->addWidget(qslRecQDateEdit, 1, 2);
QSLLayout->addWidget(qslSentViaComboBox, 0, 3);
QSLLayout->addWidget(qslRecViaComboBox, 1, 3);
//QSLLayout->setSizeConstraint(QLayout::SetFixedSize);
setLayout(QSLLayout);
connect(qslViaLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotQSLViaTextChanged() ) ) ;
connect(qslRecComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotQSLRecvComboBoxChanged() ) ) ;
connect(qslSentComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotQSLSentComboBoxChanged() ) ) ;
connect(qslViaLineEdit, SIGNAL(returnPressed()), this, SLOT(slotQSLViaLineEditReturnPressed() ) );
}
void MainWindowInputQSL::setDefaultData()
{
qslSentStatusList.clear();
qslRcvdStatusList.clear();
qslViaList.clear();
qslSentStatusList = dataProxy->getQSLSentList();
qslRcvdStatusList = dataProxy->getQSLRcvdList();
qslViaList = dataProxy->getQSLViaList();
qslSentComboBox->addItems(qslSentStatusList);
qslRecComboBox->addItems(qslRcvdStatusList);
qslRecViaComboBox->addItems(qslViaList);
qslSentViaComboBox->addItems(qslViaList);
qslSentQDateEdit->setDate(util->getDefaultDate());
qslRecQDateEdit->setDate(util->getDefaultDate());
}
void MainWindowInputQSL::clear()
{
qslSentComboBox->setCurrentIndex(1);
qslRecComboBox->setCurrentIndex(1);
qslRecViaComboBox->setCurrentIndex(0);
qslSentViaComboBox->setCurrentIndex(0);
qslSentQDateEdit->setDate(util->getDefaultDate());
qslRecQDateEdit->setDate(util->getDefaultDate());
qslmsgTextEdit->clear();
qslViaLineEdit->clear();
}
void MainWindowInputQSL::qslViaClear()
{
qslViaLineEdit->clear();
}
QString MainWindowInputQSL::getQSLRecStatus()
{
QString _pm = QString();
_pm = (((qslRecComboBox->currentText()).split('-')).at(0)).simplified();
return _pm;
}
QString MainWindowInputQSL::getQSLSenStatus()
{
QString _pm = QString();
_pm = (((qslSentComboBox->currentText()).split('-')).at(0)).simplified();
return _pm;
}
QString MainWindowInputQSL::getSentVia()
{
QString _pm = QString();
_pm = (((qslSentViaComboBox->currentText()).split('-')).at(0)).simplified();
//qDebug() << "MainWindow::getSentVia: " << _pm << QT_ENDL;
return _pm;
}
QString MainWindowInputQSL::getRecVia()
{
QString _pm = QString();
_pm = (((qslRecViaComboBox->currentText()).split('-')).at(0)).simplified();
//qDebug() << "MainWindowInputQSL::getRecVia: " << _pm << QT_ENDL;
return _pm;
}
QString MainWindowInputQSL::getQSLVia()
{
return qslViaLineEdit->text();
}
QString MainWindowInputQSL::getQSLMsg()
{
return qslmsgTextEdit->toPlainText();
}
void MainWindowInputQSL::setQSLRecStatus(const QString &_qs)
{
if(( qslRecComboBox->findText(_qs+" -", Qt::MatchStartsWith))>=0)
{
qslRecComboBox->setCurrentIndex( qslRecComboBox->findText(_qs+" -", Qt::MatchStartsWith));
}
else
{
qslRecComboBox->setCurrentIndex(1);
}
}
void MainWindowInputQSL::setQSLSenStatus(const QString &_qs)
{
if(( qslSentComboBox->findText(_qs+" -", Qt::MatchStartsWith))>=0)
{
qslSentComboBox->setCurrentIndex( qslSentComboBox->findText(_qs+" -", Qt::MatchStartsWith));
}
else
{
qslSentComboBox->setCurrentIndex(1);
}
}
void MainWindowInputQSL::setQSLRecVia(const QString &_qs)
{
if(( qslRecViaComboBox->findText(_qs+" -", Qt::MatchStartsWith))>=0)
{
qslRecViaComboBox->setCurrentIndex( qslRecViaComboBox->findText(_qs+" -", Qt::MatchStartsWith));
}
else
{
qslRecViaComboBox->setCurrentIndex(0); // bureau by default
}
}
void MainWindowInputQSL::setQSLSenVia(const QString &_qs)
{
//qDebug() << "MainWindowInputQSL::setQSLSenVia: " << _qs << QT_ENDL;
if(( qslSentViaComboBox->findText(_qs+" -", Qt::MatchStartsWith))>=0)
{
qslSentViaComboBox->setCurrentIndex( qslSentViaComboBox->findText(_qs+" -", Qt::MatchStartsWith));
}
else
{
qslSentViaComboBox->setCurrentIndex(0); // bureau by default
}
}
void MainWindowInputQSL::setQSLVia(const QString &_qs, QColor qColor)
{
palette.setColor(QPalette::Text, qColor);
qslViaLineEdit->setPalette(palette);
if (_qs.length()>0)
{
qslViaLineEdit->setText(_qs);
}
else
{
qslViaLineEdit->clear();
}
}
void MainWindowInputQSL::setQSLMsg(const QString &_qs)
{
if (_qs.length()>0)
{
qslmsgTextEdit->setText(_qs);
}
else
{
qslmsgTextEdit->clear();
}
}
QDate MainWindowInputQSL::getQSLRecDate()
{
return qslRecQDateEdit->date();
}
QDate MainWindowInputQSL::getQSLSenDate()
{
return qslSentQDateEdit->date();
}
void MainWindowInputQSL::setQSLRecDate(const QDate _qs)
{
if (_qs.isValid())
{
qslRecQDateEdit->setDate(_qs);
}
else
{
qslRecQDateEdit->clear();
}
}
void MainWindowInputQSL::setQSLSenDate(const QDate _qs)
{
if (_qs.isValid())
{
qslSentQDateEdit->setDate(_qs);
}
else
{
qslSentQDateEdit->clear();
}
}
void MainWindowInputQSL::slotQSLViaTextChanged()
{
//qDebug() << "MainWindow::slotQSLViaTextChanged: " << qslViaLineEdit->text() << " / Length: " << QString::number((qslViaLineEdit->text()).size()) << QT_ENDL;
qslViaLineEdit->setText((util->getClearSQLi(qslViaLineEdit->text())).toUpper());
}
void MainWindowInputQSL::slotQSLSentComboBoxChanged(){
int i = qslSentComboBox->currentIndex();
//{Y, N, R, I, V}
//(QSLSDATE is only valid if QSL_SENT is Y-0, Q-3, or I-4)
// Y-Yes = 0
// N-No = 1
// R-Requested = 2
// Q-Queued = 3
// I-Ignore = 4
switch (i)
{
case 0:
qslSentQDateEdit->setEnabled(true);
qslSentQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
case 2:
break;
case 3:
qslSentQDateEdit->setEnabled(true);
break;
case 4:
qslSentQDateEdit->setEnabled(true);
break;
default: //NO
qslSentQDateEdit->setEnabled(false);
break;
}
}
void MainWindowInputQSL::slotQSLRecvComboBoxChanged(){
int i = qslRecComboBox->currentIndex();
//{Y, N, R, I, V}
//(QSLSDATE is only valid if QSL_SENT is Y-0, Q-3, or I-4)
// Y-Yes = 0
// N-No = 1
// R-Requested = 2
// Q-Queued = 3
// I-Ignore = 4
switch (i)
{
case 0:
qslRecQDateEdit->setEnabled(true);
qslRecQDateEdit->setDate((QDateTime::currentDateTime()).date());
break;
case 2:
break;
case 3:
qslRecQDateEdit->setEnabled(true);
break;
case 4:
qslRecQDateEdit->setEnabled(true);
break;
default: //NO
qslRecQDateEdit->setEnabled(false);
break;
}
}
void MainWindowInputQSL::slotQSLViaLineEditReturnPressed()
{
emit returnPressed();
}
klog-1.8.6/inputwidgets/mainwindowmydatatab.cpp 0000644 0001750 0001750 00000050604 14166020407 020744 0 ustar devel devel /***************************************************************************
mainwindowmydatatab.cpp - description
-------------------
begin : Jul 2016
copyright : (C) 2016 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
#include "mainwindowmydatatab.h"
MainWindowMyDataTab::MainWindowMyDataTab(QWidget *parent) :
QWidget(parent)
{
//qDebug() << "MainWindowMyDataTab::MainWindowMyDataTab" << QT_ENDL;
myPowerSpinBox = new QDoubleSpinBox;
operatorLineEdit = new QLineEdit;
stationCallSignLineEdit = new QLineEdit;
myLocatorLineEdit = new QLineEdit;
myUserADIFLineEdit = new QLineEdit;
myUserADIFComboBox = new QComboBox;
keepThisDataForNextQSOQCheckbox = new QCheckBox;
locator = new Locator();
lastOperatorQRZ = QString(); // Last QRZ used by the user, will remain if the button is checked and removed if not
//lastStationQRZ = QString(); // Last QRZ used by the user, will remain if the button is checked and removed if not
lastMyLocator = QString(); // Last locator used by the user, will remain if the button is checked and removed if not
stationCallsign = QString(); // Defined in the configuration by the user, will be used if the user configured so in the setup
operatorQRZ = QString(); // Defined in the configuration by the user, will be used if the user configured so in the setup
myLocator = QString(); // Defined in the configuration by the user, will be used if the user configured so in the setup
util = new Utilities;
modify = false;
createUI();
setInitialADIFValues();
myPower = 0;
lastPower = 0;
//qDebug() << "MainWindowMyDataTab::MainWindowMyDataTab - END" << QT_ENDL;
}
MainWindowMyDataTab::~MainWindowMyDataTab(){}
void MainWindowMyDataTab::createUI()
{
//qDebug() << Q_FUNC_INFO;
palRed.setColor(QPalette::Text, Qt::red);
palBlack.setColor(QPalette::Text, Qt::black);
palWhite.setColor(QPalette::Text, Qt::white);
myPowerSpinBox->setDecimals(2);
myPowerSpinBox->setMaximum(9999);
myPowerSpinBox->setSuffix(" " + tr("Watts"));
keepThisDataForNextQSOQCheckbox->setText(tr("Keep this data"));
QLabel *myPowerSpinBoxLabelN = new QLabel(tr("Power"));
myPowerSpinBoxLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QLabel *operatorLabelN = new QLabel(tr("Operator callsign"));
operatorLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QLabel *stationCallSignLabelN = new QLabel(tr("Station Callsign"));
stationCallSignLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QLabel *myLocatorLabelN = new QLabel(tr("My Locator"));
myLocatorLabelN->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QGridLayout *myDataInputTabWidgetLayout = new QGridLayout;
myDataInputTabWidgetLayout->addWidget(myPowerSpinBoxLabelN, 0, 2);
myDataInputTabWidgetLayout->addWidget(myPowerSpinBox, 0, 3);
myDataInputTabWidgetLayout->addWidget(operatorLabelN, 1, 0);
myDataInputTabWidgetLayout->addWidget(operatorLineEdit, 1, 1);
myDataInputTabWidgetLayout->addWidget(stationCallSignLabelN, 1, 2);
myDataInputTabWidgetLayout->addWidget(stationCallSignLineEdit, 1, 3);
myDataInputTabWidgetLayout->addWidget(myUserADIFComboBox, 2, 0);
myDataInputTabWidgetLayout->addWidget(myUserADIFLineEdit, 2, 1);
myDataInputTabWidgetLayout->addWidget(myLocatorLabelN, 2, 2);
myDataInputTabWidgetLayout->addWidget(myLocatorLineEdit, 2, 3);
//myDataInputTabWidgetLayout->addWidget(keepLabel, 4, 2);
myDataInputTabWidgetLayout->addWidget(keepThisDataForNextQSOQCheckbox, 4, 3);
//myDataInputTabWidgetLayout->setSizeConstraint(QLayout::SetFixedSize);
setLayout(myDataInputTabWidgetLayout);
//myDataInputTabWidget->setLayout(myDataInputTabWidgetLayout);
// i = dxUpLeftTab->addTab(myDataInputTabWidget, tr("My Data"));
//connect(stationCallSignLineEdit, SIGNAL(returnPressed()), this, SLOT(slotQRZReturnPressed() ) );
connect(myLocatorLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotMyLocatorTextChanged() ) );
connect(myLocatorLineEdit, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed() ) );
connect(operatorLineEdit, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed() ) );
connect(operatorLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotOperatorTextChanged()) );
connect(stationCallSignLineEdit, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed() ) );
connect(stationCallSignLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotStationCallSignTextChanged() ) );
connect(myUserADIFComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotMyUserADIFComboBoxChanged() ) ) ;
connect(myUserADIFLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotSetCurrentMyUSerData() ) );
}
void MainWindowMyDataTab::clear(bool _full)
{
//qDebug() << Q_FUNC_INFO;
modify = false;
if (!keepThisDataForNextQSOQCheckbox->isChecked())
{
//qDebug() << "MainWindowMyDataTab::clear: NOT checked" << QT_ENDL;
myPowerSpinBox->setValue(myPower);
if (util->isValidCall(operatorQRZ))
{
//qDebug() << Q_FUNC_INFO << ": " << operatorQRZ;
operatorLineEdit->setText(operatorQRZ);
}
else
{
operatorLineEdit->clear();
}
if (util->isValidCall(stationCallsign))
{
stationCallSignLineEdit->setText(stationCallsign);
}
else
{
stationCallSignLineEdit->clear();
}
if (util->isValidGrid(myLocator))
{
myLocatorLineEdit->setText(myLocator);
}
else
{
myLocatorLineEdit->clear();
}
my_rig = QString();
my_sota = QString();
my_antenna = QString();
myUserADIFComboBox->setCurrentIndex(0);
myUserADIFLineEdit->clear();
}
if (_full)
{
operatorLineEdit->clear ();
stationCallSignLineEdit->clear ();
myLocatorLineEdit->clear ();
myPowerSpinBox->clear ();
my_rig = QString();
my_sota = QString();
my_antenna = QString();
my_vucc_grids = QString();
myUserADIFComboBox->setCurrentIndex(0);
myUserADIFLineEdit->clear();
keepThisDataForNextQSOQCheckbox->setChecked (false);
}
}
void MainWindowMyDataTab::show()
{
//qDebug() << Q_FUNC_INFO;
//qDebug() << "MainWindowMyDataTab::show: " << QString::number(myPower) << "/" << operatorQRZ << "/" << stationCallsign << "/" << myLocator << QT_ENDL;
myPowerSpinBox->setValue(myPower);
operatorLineEdit->setText(operatorQRZ);
stationCallSignLineEdit->setText(stationCallsign);
//qDebug() << "MainWindowMyDataTab::show: setMyLocator: " << myLocator << QT_ENDL;
myLocatorLineEdit->setText(myLocator);
}
void MainWindowMyDataTab::slotMyLocatorTextChanged()
{
//qDebug() << Q_FUNC_INFO;
//qDebug() << "MainWindowMyDataTab::slotMyLocatorTextChanged: " << myLocatorLineEdit->text() << QT_ENDL;
//logEvent(Q_FUNC_INFO, "Start", logSeverity);
int cursorP = myLocatorLineEdit->cursorPosition();
myLocatorLineEdit->setText(util->getClearSQLi(myLocatorLineEdit->text()).toUpper());
//qDebug() << "MainWindowMyDataTab::clear: setMyLocator: " << myLocatorLineEdit->text() << QT_ENDL;
if ( locator->isValidLocator(myLocatorLineEdit->text()))
{
if (!modify)
{
myLocator = (myLocatorLineEdit->text()).toUpper();
}
if (getDarkMode())
{
myLocatorLineEdit->setPalette(palWhite);
}
else
{
myLocatorLineEdit->setPalette(palBlack);
}
myLocatorLineEdit->setToolTip(tr("My QTH locator."));
myLocatorLineEdit->setCursorPosition(cursorP);
emit myLocChangedSignal(myLocatorLineEdit->text());
//dxccStatusWidget->setMyLocator(myLocator);
//qDebug() << "MainWindowMyDataTab::slotMyLocatorTextChanged: My LOCATOR CHANGED TO: " << myLocator << QT_ENDL;
//slotLocatorTextChanged();
}
else
{
//logEvent(Q_FUNC_INFO, "END-2", logSeverity);
myLocatorLineEdit->setPalette(palRed);
myLocatorLineEdit->setToolTip(tr("My QTH locator. Format should be Maidenhead like IN70AA up to 10 characters."));
myLocatorLineEdit->setCursorPosition(cursorP);
return;
}
//logEvent(Q_FUNC_INFO, "END", logSeverity);
}
void MainWindowMyDataTab::slotReturnPressed()
{
//qDebug() << Q_FUNC_INFO;
emit returnPressed();
}
void MainWindowMyDataTab::setSetupMyPower(const double _power)
{
//qDebug() << Q_FUNC_INFO;
myPower = _power;
myPowerSpinBox->setValue(_power);
}
void MainWindowMyDataTab::setSetupOperator(const QString &_op)
{
//qDebug() << Q_FUNC_INFO;
if (!util->isValidCall (_op))
{
return;
}
operatorQRZ = _op.toUpper();
operatorLineEdit->setText (operatorQRZ);
}
/*
void MainWindowMyDataTab::setSetupStationQRZ(const QString &_op)
{
//qDebug() << Q_FUNC_INFO << ": " << _op ;
if (!util->isValidCall (_op))
{
return;
}
stationQRZ = _op.toUpper();
stationCallSignLineEdit->setText(stationQRZ);
}
*/
void MainWindowMyDataTab::setSetupMyLocator(const QString &_op)
{
//qDebug() << Q_FUNC_INFO;
if (!locator->isValidLocator (_op))
{
return;
}
myLocator = _op.toUpper();
myLocatorLineEdit->setText (myLocator);
}
void MainWindowMyDataTab::setMyPower(const double _power)
{
//qDebug() << "MainWindowMyDataTab::setMyPower: " << QString::number(_power) << QT_ENDL;
//qDebug() << Q_FUNC_INFO;
myPowerSpinBox->setValue(_power);
}
double MainWindowMyDataTab::getMyPower()
{
//qDebug() << Q_FUNC_INFO;
if (myPowerSpinBox->value() > 0)
{
lastPower = myPowerSpinBox->value();
return lastPower;
}
else
{
return 0.0;
}
//return myPowerSpinBox->value();
}
void MainWindowMyDataTab::setOperator(const QString &_op)
{
//qDebug() << Q_FUNC_INFO << ": " << _op;
//qDebug() << Q_FUNC_INFO;
operatorLineEdit->setText(_op);
}
QString MainWindowMyDataTab::getOperator()
{
//qDebug() << Q_FUNC_INFO << ": " << (operatorLineEdit->text()).toUpper();
lastOperatorQRZ = (operatorLineEdit->text()).toUpper();
return lastOperatorQRZ;
}
void MainWindowMyDataTab::setStationCallsign(const QString &_op)
{
//qDebug() << Q_FUNC_INFO << ": " << _op;
if (util->isValidCall (_op))
{
stationCallSignLineEdit->setText(_op);
}
else
{
stationCallsign.clear ();
}
}
QString MainWindowMyDataTab::getStationCallsign()
{
//qDebug() << Q_FUNC_INFO << ": " << (stationCallSignLineEdit->text()).toUpper();
return (stationCallSignLineEdit->text()).toUpper();
//return lastStationQRZ;
}
void MainWindowMyDataTab::setMyLocator(const QString &_op)
{
//qDebug() << Q_FUNC_INFO << ": " << _op;
myLocatorLineEdit->setText(_op);
}
QString MainWindowMyDataTab::getMyLocator()
{
//qDebug() << Q_FUNC_INFO;
lastMyLocator = (myLocatorLineEdit->text()).toUpper();
return lastMyLocator.toUpper();
}
void MainWindowMyDataTab::setData(const double _power, const QString &_stationCallsign, const QString &_operator, const QString &_myLocator)
{
//qDebug() << Q_FUNC_INFO;
if (_power > 0.0)
{
myPower = _power;
}
else
{
myPower = 0;
}
if (util->isValidCall (_stationCallsign))
{
stationCallsign = _stationCallsign;
}
else
{
stationCallsign = QString();
}
//qDebug() << Q_FUNC_INFO << ": Setting station Callsign: " << stationCallsign;
setStationCallsign (stationCallsign);
if (_operator.length()>0)
{
setOperator (_operator);
//operatorQRZ = _operator;
}
else
{
operatorQRZ = QString();
}
if (_myLocator.length()>0)
{
myLocator = _myLocator;
setMyLocator (_myLocator);
}
else
{
myLocator = QString();
}
}
void MainWindowMyDataTab::slotOperatorTextChanged()
{
//qDebug() << Q_FUNC_INFO << operatorLineEdit->text();
int cursorP = operatorLineEdit->cursorPosition();
operatorLineEdit->setText(util->getClearSQLi(operatorLineEdit->text()).toUpper());
if (util->isValidCall(operatorLineEdit->text()))
{
if (getDarkMode())
{
operatorLineEdit->setPalette(palWhite);
}
else
{
operatorLineEdit->setPalette(palBlack);
}
if (!modify)
{
operatorQRZ = (operatorLineEdit->text());
}
}
else if (operatorLineEdit->text ().isEmpty ())
{
if (!modify)
{
operatorQRZ.clear ();
}
}
else
{
operatorLineEdit->setPalette(palRed);
}
operatorLineEdit->setCursorPosition(cursorP);
}
void MainWindowMyDataTab::slotStationCallSignTextChanged()
{
//qDebug() << Q_FUNC_INFO;
int cursorP = stationCallSignLineEdit->cursorPosition();
stationCallSignLineEdit->setText(util->getClearSQLi(stationCallSignLineEdit->text()).toUpper());
if (util->isValidCall(stationCallSignLineEdit->text()))
{
if (getDarkMode())
{
stationCallSignLineEdit->setPalette(palWhite);
}
else
{
stationCallSignLineEdit->setPalette(palBlack);
}
//if (!modify)
//{
// stationCallsign = (stationCallSignLineEdit->text());
//}
}
else
{
stationCallSignLineEdit->setPalette(palRed);
}
stationCallSignLineEdit->setCursorPosition(cursorP);
}
void MainWindowMyDataTab::setKeep(const bool _b)
{
//qDebug() << Q_FUNC_INFO;
keepThisDataForNextQSOQCheckbox->setChecked (_b);
}
bool MainWindowMyDataTab::getKeep()
{
//qDebug() << Q_FUNC_INFO;
return keepThisDataForNextQSOQCheckbox->isChecked ();
}
bool MainWindowMyDataTab::setInitialADIFValues()
{
//qDebug() << Q_FUNC_INFO;
adifValidTypes.clear ();
adifValidTypes << "01-" + tr("My Rig") << "02-" + tr("My Antenna") << "03-" + tr("My SOTA_Ref")<< "04-" + tr("My VUCC_GRIDS");
myUserADIFComboBox->clear ();
myUserADIFComboBox->addItems (adifValidTypes);
return true;
}
bool MainWindowMyDataTab::setUserADIFTypeComboBox(const QString &_value)
{
//qDebug() << Q_FUNC_INFO << ": " << _value;
if (_value == "MY_RIG")
{
myUserADIFComboBox->setCurrentIndex (0);
}
else if (_value == "MY_ANTENNA")
{
myUserADIFComboBox->setCurrentIndex (1);
}
else if (_value == "MY_SOTA_REF")
{
myUserADIFComboBox->setCurrentIndex (2);
}
else if (_value == "MY_VUCC_GRIDS")
{
myUserADIFComboBox->setCurrentIndex (3);
}
else
{
myUserADIFComboBox->setCurrentIndex (0);
return false;
}
return true;
}
QString MainWindowMyDataTab::getUserADIFTypeComboBox()
{
//qDebug() << Q_FUNC_INFO;
int value = (((myUserADIFComboBox->currentText ()).split('-')).at(0)).toInt ();
switch (value)
{
case 1:
return "MY_RIG";
case 2:
return "MY_ANTENNA";
case 3:
return "MY_SOTA_REF";
case 4:
return "MY_VUCC_GRIDS";
default:
return QString();
}
}
bool MainWindowMyDataTab::setUserADIFValue(const QString &_adifValue)
{
//qDebug() << Q_FUNC_INFO;
myUserADIFLineEdit->setText (_adifValue);
return true;
}
QString MainWindowMyDataTab::getUserADIFValue()
{
//qDebug() << Q_FUNC_INFO;
return myUserADIFLineEdit->text();
}
bool MainWindowMyDataTab::setMyRig(const QString &_op)
{
//qDebug() << Q_FUNC_INFO << ": " << _op;
my_rig = _op;
slotMyUserADIFComboBoxChanged();
return true;
}
QString MainWindowMyDataTab::getMyRig()
{
//qDebug() << Q_FUNC_INFO;
return my_rig;
}
bool MainWindowMyDataTab::setMyAntenna(const QString &_op)
{
//qDebug() << Q_FUNC_INFO << ": " << _op;
my_antenna = _op;
slotMyUserADIFComboBoxChanged();
return true;
}
QString MainWindowMyDataTab::getMyAntenna()
{
//qDebug() << Q_FUNC_INFO;
return my_antenna;
}
bool MainWindowMyDataTab::setMySOTA(const QString &_op)
{
//qDebug() << Q_FUNC_INFO << ": " << _op;
my_sota = _op;
slotMyUserADIFComboBoxChanged();
return true;
}
QString MainWindowMyDataTab::getMySOTA()
{
//qDebug() << Q_FUNC_INFO;
return my_sota;
}
bool MainWindowMyDataTab::setMyVUCCGrids(const QString &_op)
{
//qDebug() << Q_FUNC_INFO << ": " << _op;
if (checkMyVUCC_GRIDS(_op))
{
my_vucc_grids = _op;
slotMyUserADIFComboBoxChanged();
return true;
}
return false;
}
bool MainWindowMyDataTab::checkMyVUCC_GRIDS(const QString &_string)
{
//qDebug() << Q_FUNC_INFO << ": " << _string;
if (util->isValidVUCCGrids (_string))
{
setColorsForMyUserADIFLineEdit();
return true;
}
else
{
myUserADIFLineEdit->setPalette (palRed);
return false;
}
}
QString MainWindowMyDataTab::getMyVUCCGrids()
{
if (checkMyVUCC_GRIDS (my_vucc_grids))
{
return my_vucc_grids;
}
else
{
return QString();
}
}
void MainWindowMyDataTab::setColorsForMyUserADIFLineEdit()
{
if (getDarkMode())
{
myUserADIFLineEdit->setPalette(palWhite);
}
else
{
myUserADIFLineEdit->setPalette(palBlack);
}
}
void MainWindowMyDataTab::slotMyUserADIFComboBoxChanged()
{
//qDebug() << Q_FUNC_INFO << ": " << getUserADIFTypeComboBox ();
QString currentTag = getUserADIFTypeComboBox ();
setColorsForMyUserADIFLineEdit();
if (currentTag == "MY_RIG")
{
myUserADIFLineEdit->setText (my_rig);
}
else if (currentTag == "MY_ANTENNA")
{
myUserADIFLineEdit->setText (my_antenna);
}
else if (currentTag == "MY_SOTA_REF")
{
myUserADIFLineEdit->setText (my_sota);
}
else if (currentTag == "MY_VUCC_GRIDS")
{
myUserADIFLineEdit->setText (my_vucc_grids);
}
}
void MainWindowMyDataTab::slotSetCurrentMyUSerData()
{
QString currentTag = getUserADIFTypeComboBox ();
//qDebug() << Q_FUNC_INFO << ": " << currentTag;
int currentPos = myUserADIFLineEdit->cursorPosition ();
if (currentTag == "MY_RIG")
{
my_rig = myUserADIFLineEdit->text();
}
else if (currentTag == "MY_ANTENNA")
{
my_antenna = myUserADIFLineEdit->text();
}
else if (currentTag == "MY_SOTA_REF")
{
my_sota = myUserADIFLineEdit->text();
}
else if (currentTag == "MY_VUCC_GRIDS")
{
//if (checkMyVUCC_GRIDS(myUserADIFLineEdit->text()))
//{}
my_vucc_grids = myUserADIFLineEdit->text().toUpper();
myUserADIFLineEdit->setText (my_vucc_grids);
}
myUserADIFLineEdit->setCursorPosition (currentPos);
}
void MainWindowMyDataTab::setModify(const bool _modify)
{
//emit debugLog(Q_FUNC_INFO, "Start", Debug);
modify = _modify;
//emit debugLog(Q_FUNC_INFO, "END", Debug);
}
bool MainWindowMyDataTab::getDarkMode()
{
if (operatorLineEdit->palette().color (QPalette::Base) == "#646464")
{
return true;
}
else
{
return false;
}
}
klog-1.8.6/inputwidgets/mainwindowmydatatab.h 0000644 0001750 0001750 00000011664 14166020407 020414 0 ustar devel devel #ifndef MAINWINDOWMYDATATAB_H
#define MAINWINDOWMYDATATAB_H
/***************************************************************************
mainwindowmydatatab.h - description
-------------------
begin : jul 2016
copyright : (C) 2016 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
//
// This class implement the tab of the mainwindow that supports MY DATA
//
#include
#include
#include "../locator.h"
#include "../utilities.h"
//#include "dataproxy_sqlite.h"
//#include "dataproxy_sqlite.h"
class MainWindowMyDataTab : public QWidget
{
Q_OBJECT
public:
explicit MainWindowMyDataTab(QWidget *parent = nullptr);
~MainWindowMyDataTab();
void createUI();
void setData(const double _power, const QString &_stationCallsign, const QString &_operator, const QString &_myLocator);
void setSetupMyPower(const double _power);
void setSetupOperator(const QString &_op);
//void setSetupStationQRZ(const QString &_op);
void setSetupMyLocator(const QString &_op);
void setMyPower(const double _power);
double getMyPower();
//double getLastPower();
void setOperator(const QString &_op);
QString getOperator();
//QString getLastOperator();
void setStationCallsign(const QString &_op); // Sets ONLY the LineEdit, not the internal/configured stationCallsign
QString getStationCallsign();
//QString getLastStationQRZ();
void setMyLocator(const QString &_op);
QString getMyLocator();
bool setMyRig(const QString &_op);
QString getMyRig();
bool setMyAntenna(const QString &_op);
QString getMyAntenna();
bool setMySOTA(const QString &_op);
QString getMySOTA();
bool setMyVUCCGrids(const QString &_op);
QString getMyVUCCGrids(); // Returns the VUCC list in LOC1, LOC2 or LOC1,LOC2, LOC3, LOC4 format
bool setUserADIFTypeComboBox(const QString &_value);
QString getUserADIFTypeComboBox();
bool setUserADIFValue(const QString &_adifValue);
QString getUserADIFValue();
void show(); //Shows the values into the widget
void clear(bool _full = false); //full= false leaves the "keep this data"; full = true clears everything
void setKeep(const bool _b);
bool getKeep();
void setModify(const bool _modify);
signals:
void myLocChangedSignal(const QString &_q); // MyLocator once updated
void returnPressed();
private slots:
void slotMyLocatorTextChanged();
void slotOperatorTextChanged();
void slotStationCallSignTextChanged();
void slotReturnPressed();
void slotMyUserADIFComboBoxChanged();
void slotSetCurrentMyUSerData();
private:
bool setInitialADIFValues();
void setColorsForMyUserADIFLineEdit();
bool checkMyVUCC_GRIDS(const QString &_string);
QStringList adifValidTypes;
QDoubleSpinBox *myPowerSpinBox;
QString stationCallsign, operatorQRZ, myLocator; //Not changed during normal operations. They come from the configuration
QString lastOperatorQRZ, lastMyLocator; //lastStationQRZ, Change dinamically during execution
double myPower, lastPower;
QLineEdit *operatorLineEdit, *stationCallSignLineEdit, *myLocatorLineEdit, *myUserADIFLineEdit;
QComboBox *myUserADIFComboBox;
QCheckBox *keepThisDataForNextQSOQCheckbox;
QPalette palRed, palBlack, palWhite; // To paint Text in red or black(normal)
Locator *locator;
Utilities *util;
bool modify;
QString my_rig, my_sota, my_antenna, my_vucc_grids;
bool getDarkMode();
};
#endif // MAINWINDOWMYDATATAB_H
klog-1.8.6/inputwidgets/mainwindowinputqso.h 0000644 0001750 0001750 00000010350 14166020407 020317 0 ustar devel devel #ifndef MAINWINDOWINPUTQSO_H
#define MAINWINDOWINPUTQSO_H
/***************************************************************************
mainwindowinputqso.h - description
-------------------
begin : may 2021
copyright : (C) 2021 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
//
// This class implement the tab of the mainwindow that supports the QSL options
//
#include
#include
#include "../dataproxy_sqlite.h"
#include "../locator.h"
#include "../utilities.h"
class MainWindowInputQSO : public QWidget
{
Q_OBJECT
public:
explicit MainWindowInputQSO(DataProxy_SQLite *dp, QWidget *parent = nullptr);
~MainWindowInputQSO();
void setPaletteRightName(const bool _ok);
void setPaletteRightQTH(const bool _ok);
void setPaletteRightDXLocator(const bool _ok);
QString getDXLocator();
void setDXLocator(const QString &_loc);
QString getName();
void setName(const QString &_st);
QString getQTH();
void setQTH(const QString &_st);
void setRSTToMode(const QString &_m, const bool _reading = true);
QString getRSTTX();
void setRSTTX(const QString &_st);
QString getRSTRX();
void setRSTRX(const QString &_st);
double getTXFreq();
void setTXFreq(const double _ft);
double getRXFreq();
void setRXFreq(const double _ft);
void setPropModeFromSat(const QString &_p);
double getRXPwr();
void setRXPwr(const double _pw);
void setModifying(const bool _m);
void receiveFocus();
void clear();
void cleanQRZCOM();
void clearName();
void clearQTH();
void clearDXLocator();
signals:
void returnPressed();
void dxLocatorChanged(QString _loc);
void rxFreqChanged(double _f);
//void rxFreqChangedForSat(double _f);
//void txFreqBeingChanged(bool _f);
void txFreqChanged(double _f);
void handOverFocusSignal();
//void txFreqChangedForSat(double _f);
private slots:
void slotReturnPressed();
void slotLocatorTextChanged();
void slotFreqTXChanged (double _f);
void slotFreqRXChanged (double _f);
void slotSplitClicked();
private:
bool eventFilter(QObject *object, QEvent *event);
void createUI();
void setDefaultData();
bool getDarkMode();
void setSplitCheckBox();
QLineEdit *rstTXLineEdit, *rstRXLineEdit, *qthLineEdit, *locatorLineEdit, *nameLineEdit;
QDoubleSpinBox *rxPowerSpinBox, *txFreqSpinBox, *rxFreqSpinBox;
QCheckBox *splitCheckBox;
Locator *locator;
DataProxy_SQLite *dataProxy;
Utilities *util;
QPalette palRed, palBlack, palWhite; // To paint Text in red or black(normal)
bool rxFreqBeingAutoChanged, txFreqBeingAutoChanged, isSATPropagation;
QString propMode;
double freqTX, freqRX;
bool modify;
};
#endif // MAINWINDOWINPUTQSO_H
klog-1.8.6/inputwidgets/mainwindowsattab.cpp 0000644 0001750 0001750 00000077064 14166020421 020261 0 ustar devel devel
/***************************************************************************
mainwindowsattab.cpp - description
-------------------
begin : Jul 2016
copyright : (C) 2016 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
#include "mainwindowsattab.h"
/*
This class implements the Satellite TAB of the MainWindow
*/
MainWindowSatTab::MainWindowSatTab(DataProxy_SQLite *dp, QWidget *parent) :
QWidget(parent)
{
//qDebug() << "MainWindowSatTab::MainWindowSatTab" << QT_ENDL;
satNameComboBox = new QComboBox;
satNameLineEdit = new QLineEdit;
satModeLineEdit = new QLineEdit;
satDXLocatorLineEdit = new QLineEdit;
satOtherLabel = new QLabel;
satBandTXComboBox = new QComboBox;
satBandRXComboBox = new QComboBox;
txFreqSpinBox = new QDoubleSpinBox;
rxFreqSpinBox = new QDoubleSpinBox;
keepThisDataForNextQSOQcheckbox = new QCheckBox;
dataProxy = dp;
locator = new Locator;
util = new Utilities;
createUI();
populateSatComboBox();
//txBandBeingChanged = false;
//rxBandBeingChanged = false;
modifying = false;
//txBandsBeingChanged = false;
updatingBands = false;
satNameLineEdit->setEnabled(false);
satOtherLabel->setEnabled(false);
palRed.setColor(QPalette::Text, Qt::red);
palBlack.setColor(QPalette::Text, Qt::black);
palWhite.setColor(QPalette::Text, Qt::white);
setDefaultBands(); //TODO: Check how the bands are included not to create an inconsistence with the selected (in the setup) bands
//qDebug() << "MainWindowSatTab::MainWindowSatTab - END" << QT_ENDL;
}
MainWindowSatTab::~MainWindowSatTab(){}
void MainWindowSatTab::createUI()
{
connect(satNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotSatNameTextChanged() ) );
connect(satModeLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotSatModeTextChanged() ) );
connect(satDXLocatorLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotSatDXLocTextChanged() ) );
connect(satNameLineEdit, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()) );
connect(satModeLineEdit, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()) );
connect(satDXLocatorLineEdit, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()) );
connect(satNameComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSatNameComboBoxChanged() ) ) ;
connect(satBandRXComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSatBandRXComboBoxChanged()) ) ;
connect(satBandTXComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSatBandTXComboBoxChanged()) ) ;
connect(txFreqSpinBox, SIGNAL(valueChanged(double)), this, SLOT(slotSatFreqTXChanged(double)) ) ;
connect(rxFreqSpinBox, SIGNAL(valueChanged(double)), this, SLOT(slotSatFreqRXChanged(double)) ) ;
connect (keepThisDataForNextQSOQcheckbox, SIGNAL(clicked()), this, SLOT(slotSatKeepThisDataClicked()) );
QLabel *keepLabel = new QLabel();
keepLabel->setText(tr("Keep this data"));
keepLabel->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
keepLabel->setToolTip(tr("Data entered in this tab will be copied into the next QSO."));
keepThisDataForNextQSOQcheckbox->setToolTip(tr("Data entered in this tab will be copied into the next QSO."));
QString othersat = tr("Other - Sat not in the list");
QString aux;
aux.clear();
aux = QString(tr("Name of the Satellite if not in the list. Select: \"%1\" to enable this box. (format like AO-51).").arg(othersat));
satNameLineEdit->setToolTip(aux);
//satNameLineEdit->setToolTip(tr("Name of the Satellite if not in the list. Select Other Sat (format like AO-51)"));
satModeLineEdit->setToolTip(tr("Satellite mode used."));
satNameComboBox->setToolTip(tr("Select the satellite you are using."));
satBandTXComboBox->setToolTip(tr("UpLink band."));
satBandRXComboBox->setToolTip(tr("DownLink band."));
satDXLocatorLineEdit->setToolTip(tr("Locator of the DX station. This box is synchronized with the Locator box in the QSO tab."));
QLabel *upLinkLabel = new QLabel();
upLinkLabel->setText(tr("UpLink"));
upLinkLabel->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QLabel *downLinkLabel = new QLabel();
downLinkLabel->setText(tr("DownLink"));
downLinkLabel->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QLabel *satNameLabel = new QLabel();
satNameLabel->setText(tr("Satellite"));
satNameLabel->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QLabel *satModeLabel = new QLabel();
satModeLabel->setText(tr("Mode"));
satModeLabel->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
QLabel *satDXLocLabel = new QLabel();
satDXLocLabel->setText(tr("DX Locator"));
satDXLocLabel->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
//QLabel *satOtherLabel = new QLabel();
satOtherLabel->setText(tr("Other"));
satOtherLabel->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
txFreqSpinBox->setDecimals(3);
txFreqSpinBox->setMaximum(99999);
txFreqSpinBox->setSuffix(" " + tr("MHz"));
rxFreqSpinBox->setDecimals(3);
rxFreqSpinBox->setMaximum(99999);
rxFreqSpinBox->setSuffix(" " + tr("MHz"));
QHBoxLayout *keepLayout = new QHBoxLayout;
keepLayout->addWidget(keepLabel);
keepLayout->addWidget(keepThisDataForNextQSOQcheckbox);
QHBoxLayout *lastlineLayout = new QHBoxLayout;
//lastlineLayout->addWidget(satModeLabel);
lastlineLayout->addWidget(satModeLineEdit);
lastlineLayout->addWidget(satDXLocLabel);
lastlineLayout->addWidget(satDXLocatorLineEdit);
QGridLayout *tabLayout = new QGridLayout;
tabLayout->addWidget(satNameLabel,0,0);
tabLayout->addWidget(upLinkLabel,1,0);
tabLayout->addWidget(downLinkLabel,2,0);
tabLayout->addWidget(satModeLabel,3,0);
tabLayout->addLayout(lastlineLayout,3,1);
tabLayout->addWidget(satNameComboBox,0,1);
tabLayout->addWidget(satBandTXComboBox,1,1);
tabLayout->addWidget(satBandRXComboBox,2,1);
//tabLayout->addWidget(satModeLineEdit,3,1);
//tabLayout->addWidget(satModeLineEdit,3,1,1,-1);
tabLayout->addWidget(satNameLineEdit,0,2);
tabLayout->addWidget(txFreqSpinBox,1,2);
tabLayout->addWidget(rxFreqSpinBox,2,2);
tabLayout->addLayout(keepLayout,3,2);
tabLayout->setSizeConstraint(QLayout::SetFixedSize);
setLayout(tabLayout);
}
void MainWindowSatTab::slotSatNameComboBoxChanged()
{
//qDebug() << "MainWindowSatTab::slotSatNameComboBoxChanged: " << satNameComboBox->currentText() << QT_ENDL;
if (modifying || (satNameComboBox->currentText().length()<4))
{
return;
}
int i = satNameComboBox->currentIndex();
//qDebug() << "MainWindowSatTab::slotSatNameComboBoxChanged: " << QString::number(i) << QT_ENDL;
//QString _pm = (((satNameComboBox->currentText()).split(' ')).at(0)).simplified();
satNameLineEdit->clear();
if (i == 0)
{
emit setPropModeSat("Not", false);
satNameLineEdit->setEnabled(false);
satOtherLabel->setEnabled(false);
satModeLineEdit->clear();
}
else if(i == 1)
{
emit setPropModeSat("SAT", keepThisDataForNextQSOQcheckbox->isChecked());
satNameLineEdit->setEnabled(true);
satOtherLabel->setEnabled(true);
}
else
{
emit setPropModeSat("SAT", keepThisDataForNextQSOQcheckbox->isChecked());
satNameLineEdit->setEnabled(false);
satOtherLabel->setEnabled(false);
setBandsOfSat(satNameComboBox->currentText());
//dataProxy->getSatelliteMode(satNameComboBox->currentText())
}
//autofillSatMode();
}
void MainWindowSatTab::slotSatNameTextChanged()
{
//qDebug() << "MainWindowSatTab::slotSatNameTextChanged: " << satNameLineEdit->text() << QT_ENDL;
int cursor = satNameLineEdit->cursorPosition ();
satNameLineEdit->setText((util->getClearSQLi (satNameLineEdit->text())).toUpper());
if (modifying )
{
satNameLineEdit->setCursorPosition (cursor);
return;
}
if ((satNameLineEdit->text()).length()>0)
{
emit setPropModeSat("SAT", keepThisDataForNextQSOQcheckbox->isChecked());
}
else if ((satModeLineEdit->text()).length()<1)
{
emit setPropModeSat("Not", false);
}
satNameLineEdit->setCursorPosition (cursor);
}
void MainWindowSatTab::slotSatModeTextChanged()
{
//qDebug() << "MainWindowSatTab::slotSatModeTextChanged: " << satModeLineEdit->text() << QT_ENDL;
/*
satModeLineEdit->setText((satModeLineEdit->text()).toUpper());
if ((satModeLineEdit->text()).length()>0)
{
emit setPropModeSat("SAT");
}
else if ((satNameLineEdit->text()).length()<1)
{
emit setPropModeSat("Not");
}
*/
}
void MainWindowSatTab::setLocator(const QString &_t)
{
//qDebug() << "MainWindowSatTab::setLocator: " << _t << QT_ENDL;
satDXLocatorLineEdit->setText(_t.toUpper());
//qDebug() << "MainWindowSatTab::setLocator - END: " << QT_ENDL;
}
void MainWindowSatTab::slotSatDXLocTextChanged()
{
//qDebug() << "MainWindowSatTab::slotSatDXLocTextChanged: " << satDXLocatorLineEdit->text() << QT_ENDL;
int cursorP = satDXLocatorLineEdit->cursorPosition();
satDXLocatorLineEdit->setText((util->getClearSQLi(satDXLocatorLineEdit->text())).toUpper());
if ( locator->isValidLocator(satDXLocatorLineEdit->text()) )
{
if (getDarkMode())
{
satDXLocatorLineEdit->setPalette(palWhite);
}
else
{
satDXLocatorLineEdit->setPalette(palBlack);
}
satDXLocatorLineEdit->setToolTip(tr("Locator of the DX station. This box is synchronized with the Locator box in the QSO tab."));
//if (!modifying)
//{
// emit dxLocatorChanged((satDXLocatorLineEdit->text()).toUpper());
//}
}
else
{
satDXLocatorLineEdit->setPalette(palRed);
satDXLocatorLineEdit->setToolTip(tr("Locator of the DX station. Format should be Maidenhead like IN70AA up to 10 characters."));
}
satDXLocatorLineEdit->setCursorPosition(cursorP);
emit dxLocatorChanged(satDXLocatorLineEdit->text());
//qDebug() << "MainWindowSatTab::slotSatDXLocTextChanged - END" << QT_ENDL;
}
QString MainWindowSatTab::getSatName()
{
// Sat name must follow the format CC-NN to make it compatible with LOTW
// C = Character
// N = Number
/*
QString satName;
satName = satNameLineEdit->text();
//TODO: Check that the format is OK
return satName;
*/
//qDebug() << "MainWindowSatTab::getSatName:" << satNameComboBox->currentText() << QT_ENDL;
QString _pm = QString();
QString satName = QString();
_pm = (((satNameComboBox->currentText()).split(' ')).at(0)).simplified();
//qDebug() << "MainWindowSatTab::satNameComboBox: " << _pm << QT_ENDL;
if (satNameComboBox->currentIndex() == 0)
{
return QString();
}
else if(satNameComboBox->currentIndex() == 1)
{
satName = satNameLineEdit->text();
if (satName.length()>0)
{
return satName;
}
else
{
return QString();
}
}
else
{
return _pm;
}
}
void MainWindowSatTab::setNoSat()
{
satNameComboBox->setCurrentIndex(0);
keepThisDataForNextQSOQcheckbox->setChecked(false);
}
void MainWindowSatTab::setSatName(const QString &_t)
{
//TODO: Check that the format is OK
//qDebug() << "MainWindowSatTab::setSatName: " << _t << QT_ENDL;
//satNameLineEdit->setText(_t);
if (getSatIndex(_t) > 0)
{
setSatelliteCombo(_t);
}
else
{
satNameComboBox->setCurrentIndex(1);
satNameLineEdit->setText(_t);
}
}
QString MainWindowSatTab::getSatMode()
{
//qDebug() << "MainWindowSatTab::getSatMode: " << satModeLineEdit->text() << QT_ENDL;
return satModeLineEdit->text();
}
void MainWindowSatTab::setSatMode(const QString &_t)
{
//qDebug() << "MainWindowSatTab::setSatMode: " << _t ;
if (_t == "-CLEAR-")
{
satModeLineEdit->clear();
}
else
{
satModeLineEdit->setText(_t);
}
}
bool MainWindowSatTab::getRepeatThis()
{
//qDebug() << "MainWindowSatTab::getRepeatThis: " << QT_ENDL;
return keepThisDataForNextQSOQcheckbox->isChecked();
}
void MainWindowSatTab::setRepeatThis(const bool _t)
{
//qDebug() << "MainWindowSatTab::setRepeatThis: " << QT_ENDL;
keepThisDataForNextQSOQcheckbox->setChecked(_t);
}
void MainWindowSatTab::clear(bool _full)
{
//qDebug() << "MainWindowSatTab::clear" << QT_ENDL;
modifying = false;
if ((keepThisDataForNextQSOQcheckbox->isChecked()) || (!_full))
{
satDXLocatorLineEdit->clear();
}
else
{
satModeLineEdit->clear();
satNameComboBox->setCurrentIndex(0);
satNameLineEdit->clear();
satDXLocatorLineEdit->clear();
}
if (_full)
{
keepThisDataForNextQSOQcheckbox->setChecked (false);
}
}
void MainWindowSatTab::refreshData()
{
//qDebug() << "MainWindowSatTab::refreshData" << QT_ENDL;
populateSatComboBox();
//autofillSatMode();
}
void MainWindowSatTab::populateSatComboBox()
{
//qDebug() << "MainWindowSatTab::populateSatComboBox: " << QT_ENDL;
QString nosat = tr("Not Sat QSO");
QString othersat = tr("Other - Sat not in the list");
satellitesList.clear();
satellitesList = dataProxy->getSatellitesList();
satellitesList.prepend(othersat);
satellitesList.prepend("No-SAT - " + nosat);
if (satellitesList.size()>1)
{
satNameComboBox->clear();
satNameComboBox->addItems(satellitesList);
}
else
{
//TODO: Check how to do it better... now I could simply remove the if
satNameComboBox->addItems(satellitesList);
}
}
void MainWindowSatTab::setSatelliteCombo(const QString &_p)
{
//qDebug() << "MainWindowsatTab::setSatelliteCombo: " << _p << QT_ENDL;
QString aux = QString();
int indexC = getSatIndex(_p);
//int indexC = satNameComboBox->findText(_p, Qt::MatchContains);
//qDebug() << "MainWindowsatTab::setSatelliteCombo: N=" << QString::number(indexC) << QT_ENDL;
if (indexC>0)
{
satNameComboBox->setCurrentIndex(indexC);
}
else
{
satNameComboBox->setCurrentIndex(0);
if (_p.length()>0)
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
aux = tr("KLog has detected a satellite name that it does not recognise. If it should use one of the names of known satellites instead, please select it from the list. Alternatively, please contact the development team to add the new satellite name.") + "\n\n";
msgBox.setText(aux + tr("The satellite you have in your QSO is: ") + _p + "\n\n" + tr("Please be aware that the satellite name will not be saved if it is not in the list, so that information may be lost!"));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret)
{
case QMessageBox::Ok:
break;
default:
// should never be reached
break;
}
}
}
}
void MainWindowSatTab::setOtherSatName(const QString &_t)
{
//qDebug() << "MainWindowsatTab::setOtherSatName: " << _t << QT_ENDL;
satNameLineEdit->setText(_t);
}
QString MainWindowSatTab::getOtherSatName()
{
//qDebug() << "MainWindowSatTab::getOtherSatName" << QT_ENDL;
return QString();
}
int MainWindowSatTab::getSatIndex(const QString &_p)
{
//qDebug() << "MainWindowSatTab::getSatIndex: " << QString::number(satNameComboBox->findText(_p, Qt::MatchContains)) << QT_ENDL;
return satNameComboBox->findText(_p, Qt::MatchContains);
}
void MainWindowSatTab::addBands(QStringList _bands)
{
//qDebug() << "MainWindowSatTab::addBands: " << QString::number(_bands.length()) << QT_ENDL;
updatingBands = true;
QString _txBand = satBandTXComboBox->currentText();
QString _rxBand = satBandRXComboBox->currentText();
//txBandsBeingChanged = true;
satBandRXComboBox->clear();
satBandTXComboBox->clear();
satBandTXComboBox->addItems(_bands);
satBandRXComboBox->addItems(_bands);
satBandTXComboBox->setCurrentIndex(satBandTXComboBox->findText(_txBand, Qt::MatchCaseSensitive));
satBandRXComboBox->setCurrentIndex(satBandRXComboBox->findText(_rxBand, Qt::MatchCaseSensitive));
//txBandsBeingChanged = false;
updatingBands = false;
//qDebug() << "MainWindowSatTab::addBands - END" << QT_ENDL;
}
void MainWindowSatTab::setDefaultBands()
{//Defines the default bands for SAT communications: 10m/2m/70cm/23CM only if they exist in the selected bands
//qDebug() << "MainWindowsatTab::setDefaultBands: " << QT_ENDL;
QStringList _b;
_b.clear();
_b << "10M" << "2M" << "70CM" << "23CM";
satBandRXComboBox->addItems(_b);
satBandTXComboBox->addItems(_b);
}
void MainWindowSatTab::slotSatBandRXComboBoxChanged()
{
//qDebug() << "MainWindowsatTab::slotSatBandRXComboBoxChanged" << QT_ENDL;
if (updatingBands || modifying)
{
return;
}
bool freqInBand = dataProxy->isThisFreqInBand(satBandRXComboBox->currentText(), QString::number(rxFreqSpinBox->value()));
if(!freqInBand)
{ // If the freq does not belong to the current band, we need to update the band
rxFreqSpinBox->setValue(dataProxy->getLowLimitBandFromBandName(satBandRXComboBox->currentText()));
}
//qDebug() << "MainWindowsatTab::slotSatBandRXComboBoxChanged-END" << QT_ENDL;
autofillSatMode();
}
void MainWindowSatTab::slotSatFreqRXChanged(const double _f)
{
//qDebug() << Q_FUNC_INFO << ": spingBox: " << QString::number(rxFreqSpinBox->value()) << QT_ENDL;
//qDebug() << Q_FUNC_INFO << ": f: " << QString::number(_f) << QT_ENDL;
//qDebug() << Q_FUNC_INFO << ": freqRx:" << QString::number(freqRX) << QT_ENDL;
if (util->isSameFreq (freqRX, _f))
{
return;
}
freqRX = _f;
if (getDarkMode())
{
rxFreqSpinBox->setPalette(palWhite);
}
else
{
rxFreqSpinBox->setPalette(palBlack);
}
if (modifying)
{
return;
}
int bandId = dataProxy->getBandIdFromFreq(rxFreqSpinBox->value());
if (bandId<1)
{ //This prevent that a non-hamradio frequency is used on TX
//qDebug() << Q_FUNC_INFO << ": Not in band, exiting... " << QT_ENDL;
rxFreqSpinBox->setToolTip(tr("RX Frequency in MHz.\nFrequency is not in a hamradio band!"));
rxFreqSpinBox->setPalette(palRed);
}
else
{
rxFreqSpinBox->setToolTip(tr("RX Frequency in MHz."));
bool freqInBand = dataProxy->isThisFreqInBand(satBandRXComboBox->currentText(), QString::number(rxFreqSpinBox->value()));
if(!freqInBand)
{ // If the freq does not belong to the current band, we need to update the band
satBandRXComboBox->setCurrentIndex(satBandRXComboBox->findText(dataProxy->getBandNameFromFreq(rxFreqSpinBox->value()), Qt::MatchCaseSensitive));
}
}
emit satRxFreqChanged(rxFreqSpinBox->value());
//qDebug() << Q_FUNC_INFO << " - END";
}
void MainWindowSatTab::slotSatBandTXComboBoxChanged()
{
//qDebug() << "MainWindowsatTab::slotSatBandTXComboBoxChanged: -" << satBandTXComboBox->currentText() << QT_ENDL;
if (updatingBands || modifying || (satBandTXComboBox->currentText().length()<2))
{
return;
}
bool freqInBand = dataProxy->isThisFreqInBand(satBandTXComboBox->currentText(), QString::number(txFreqSpinBox->value()));
if(!freqInBand)
{ // If the freq does not belong to the current band, we need to update the band
//qDebug() << "MainWindowsatTab::slotSatBandTXComboBoxChanged changing to: Band: " << satBandTXComboBox->currentText() << QT_ENDL;
//qDebug() << "MainWindowsatTab::slotSatBandTXComboBoxChanged changing to: " << QString::number(dataProxy->getLowLimitBandFromBandName(satBandTXComboBox->currentText())) << QT_ENDL;
txFreqSpinBox->setValue(dataProxy->getLowLimitBandFromBandName(satBandTXComboBox->currentText()));
//setUpLinkFreq(dataProxy->getLowLimitBandFromBandName(satBandTXComboBox->currentText()));
}
//qDebug() << "MainWindowsatTab::slotSatBandTXComboBoxChanged-END" << QT_ENDL;
autofillSatMode();
}
void MainWindowSatTab::slotSatFreqTXChanged(const double _f)
{
//qDebug() << "MainWindowsatTab::slotSatFreqTXChanged: " << QString::number(txFreqSpinBox->value()) << QT_ENDL;
// user changes TX Freq
// If band is real and band is configured, bandcombo is selected
// If band is real and not configured, we launch the band config and select the band.
// if band is real emit the band
if (util->isSameFreq (freqTX, _f))
{
return;
}
freqTX = _f;
if (getDarkMode())
{
txFreqSpinBox->setPalette(palWhite);
}
else
{
txFreqSpinBox->setPalette(palBlack);
}
if (modifying)
{
return;
}
int bandId = dataProxy->getBandIdFromFreq(txFreqSpinBox->value());
if (bandId<1)
{ //This prevent that a non-hamradio frequency is used on TX
//qDebug() << "MainWindowsatTab::slotSatFreqTXChanged: Not in band, exiting... " << QT_ENDL;
txFreqSpinBox->setToolTip(tr("TX Frequency in MHz.\nFrequency is not in a hamradio band!"));
txFreqSpinBox->setPalette(palRed);
}
else
{
txFreqSpinBox->setToolTip(tr("TX Frequency in MHz."));
bool freqInBand = dataProxy->isThisFreqInBand(satBandTXComboBox->currentText(), QString::number(txFreqSpinBox->value()));
if(!freqInBand)
{ // If the freq does not belong to the current band, we need to update the band
//qDebug() << "MainWindowsatTab::slotSatFreqTXChanged: If the freq does not belong to the current band, we need to update the band" << QT_ENDL;
//qDebug() << "MainWindowsatTab::slotSatFreqTXChanged: We define UoLink to: " << dataProxy->getBandNameFromFreq(txFreqSpinBox->value()) << QT_ENDL;
satBandTXComboBox->setCurrentIndex(satBandTXComboBox->findText(dataProxy->getBandNameFromFreq(txFreqSpinBox->value()), Qt::MatchCaseSensitive));
//setUpLinkFreq(dataProxy->getLowLimitBandFromBandName(satBandTXComboBox->currentText()));
}
//autofillSatMode();
}
//qDebug() << "MainWindowsatTab::slotSatFreqTXChanged: Emitting: " << QString::number(txFreqSpinBox->value()) << QT_ENDL;
emit satTxFreqChanged(txFreqSpinBox->value());
//qDebug() << "MainWindowsatTab::slotSatFreqTXChanged-END" << QT_ENDL;
}
void MainWindowSatTab::setUpLink(const QString &_t)
{
//qDebug() << "MainWindowsatTab::setUpLink: " << _t << QT_ENDL;
if (satBandTXComboBox->currentText () == _t)
{
return;
}
int index = satBandTXComboBox->findText(_t, Qt::MatchCaseSensitive);
//qDebug() << "MainWindowsatTab::setUpLink: new index: " << QString::number(index) << QT_ENDL;
//qDebug() << "MainWindowsatTab::setUpLink: current index: " << QString::number(satBandTXComboBox->currentIndex()) << QT_ENDL;
int indexRX;
if (index>=0)
{
satBandTXComboBox->setCurrentIndex(index);
if ( dataProxy->getIdFromBandName("2M") == dataProxy->getIdFromBandName(_t) )
{
//qDebug() << satNameComboBox->currentText() << QT_ENDL;
if (satNameComboBox->findText("AO-7 - AMSAT-OSCAT 7", Qt::MatchCaseSensitive))
{
indexRX = satBandRXComboBox->findText("10M", Qt::MatchCaseSensitive);
}
else
{
indexRX = satBandRXComboBox->findText("70CM", Qt::MatchCaseSensitive);
}
satBandRXComboBox->setCurrentIndex(indexRX);
}
else if ( dataProxy->getIdFromBandName("70CM") == dataProxy->getIdFromBandName(_t) )
{
indexRX = satBandRXComboBox->findText("2M", Qt::MatchCaseSensitive);
satBandRXComboBox->setCurrentIndex(indexRX);
}
}
}
void MainWindowSatTab::setUpLinkFreq(const double _t)
{
//qDebug() << "MainWindowsatTab::setUpLinkFreq: " << QString::number(_t) << QT_ENDL;
if (util->isSameFreq (freqTX, _t))
{
return;
}
txFreqSpinBox->setValue(_t);
setUpLink(dataProxy->getBandNameFromFreq(_t));
//qDebug() << "MainWindowsatTab::setUpLinkFreq END" << QT_ENDL;
}
double MainWindowSatTab::getRXFreq()
{
//qDebug() << "MainWindowsatTab::getRXFreq " << QT_ENDL;
return rxFreqSpinBox->value();
}
void MainWindowSatTab::setDownLinkFreq(const double _t)
{
//qDebug() << "MainWindowsatTab::setDownLinkFreq: " << QString::number(_t) << QT_ENDL;
if (util->isSameFreq (freqRX, _t))
{
//qDebug() << Q_FUNC_INFO << " - I same freq";
return;
}
rxFreqSpinBox->setValue(_t);
QString downLinkBand = dataProxy->getBandNameFromFreq(_t);
int index = satBandRXComboBox->findText(downLinkBand, Qt::MatchCaseSensitive);
if (index>=0)
{
satBandRXComboBox->setCurrentIndex(index);
}
//qDebug() << "MainWindowsatTab::setDownLinkFreq END" << QT_ENDL;
}
void MainWindowSatTab::setBandsOfSat(const QString &_p)
{
// Until the data is in the DB, this function tries to solve data of active sats from: http://www.amsat.org/status/
// This functio:
// - identifies the freqs & bands that the sat is using
//qDebug() << "MainWindowSatTab::setBandsOfSat: " << _p << " - Short: " << _p.section(' ', 0, 0) << QT_ENDL;
//"AO-7 - AMSAT-OSCAT 7"
//2M/10M << 2M/70CM
if (modifying)
{
return;
}
double upLink = (dataProxy->getSatelliteUplink(_p.section(' ', 0, 0))).toDouble();
double downLink = (dataProxy->getSatelliteDownlink(_p.section(' ', 0, 0))).toDouble();
//qDebug() << "MainWindowSatTab::setBandsOfSat upLink: " << QString::number(upLink)<< QT_ENDL;
//qDebug() << "MainWindowSatTab::setBandsOfSat downLink: " << QString::number(downLink)<< QT_ENDL;
if (upLink>0)
{
//qDebug() << "MainWindowSatTab::setBandsOfSat upLink: emitting: " << QString::number(upLink)<< QT_ENDL;
emit satTXFreqNeeded(upLink);
//qDebug() << "MainWindowSatTab::setBandsOfSat upLink: emitted: " << QString::number(upLink)<< QT_ENDL;
}
else
{
//qDebug() << "MainWindowSatTab::setBandsOfSat upLink: setting to ZERO (should be = RX) " << QT_ENDL;
txFreqSpinBox->setValue(0);
//satBandTXComboBox->setCurrentIndex(0);
}
if (downLink>0)
{
//qDebug() << "MainWindowSatTab::setBandsOfSat downLink: emitting: " << QString::number(downLink)<< QT_ENDL;
emit satRXFreqNeeded(downLink);
//qDebug() << "MainWindowSatTab::setBandsOfSat downLink: emitted: " << QString::number(downLink)<< QT_ENDL;
}
else
{
//qDebug() << "MainWindowSatTab::setBandsOfSat downLink: setting to ZERO" << QT_ENDL;
rxFreqSpinBox->setValue(0);
//satBandRXComboBox->setCurrentIndex(0);
}
//qDebug() << "MainWindowSatTab::setBandsOfSat downLink: emiting: " << QString::number(downLink)<< QT_ENDL;
//emit satRxFreqChanged(downLink);
//qDebug() << "MainWindowSatTab::setBandsOfSat: " << _p << " - END " << QT_ENDL;
}
void MainWindowSatTab::addNewBand(const QString &_p)
{
//qDebug() << "MainWindowSatTab::addNewBand: " << _p << QT_ENDL;
if (dataProxy->getIdFromBandName(_p)<0)
{
//qDebug() << "MainWindowSatTab::addNewBand: Id: " << QString::number(dataProxy->getIdFromBandName(_p)) << QT_ENDL;
return;
}
QStringList bands;
bands.clear();
//qDebug() << "MainWindowSatTab::addNewBand: RX Id: " << QString::number(satBandRXComboBox->count()) << QT_ENDL;
//qDebug() << "MainWindowSatTab::addNewBand: TX Id: " << QString::number(satBandTXComboBox->count()) << QT_ENDL;
for (int i = 0; i < satBandTXComboBox->count(); i++)
{
bands << satBandTXComboBox->itemText(i);
for (int ii = 0; ii < satBandRXComboBox->count(); ii++)
{
bands << satBandRXComboBox->itemText(ii);
}
}
bands << _p;
//bands.removeDuplicates();
emit newBandsToBeAdded(bands);
//addBands(bands);
//qDebug() << "MainWindowSatTab::addNewBand: 2 RX Id: " << QString::number(satBandRXComboBox->count()) << QT_ENDL;
//qDebug() << "MainWindowSatTab::addNewBand: 2 TX Id: " << QString::number(satBandTXComboBox->count()) << QT_ENDL;
}
void MainWindowSatTab::setModifying (const bool _m)
{
//qDebug() << "MainWindowsatTab::setModifying" << QT_ENDL;
modifying = _m;
}
void MainWindowSatTab::slotReturnPressed()
{
//qDebug() << "MainWindowsatTab::slotReturnPressed" << QT_ENDL;
emit returnPressed();
}
void MainWindowSatTab::slotSatKeepThisDataClicked()
{
//qDebug() << Q_FUNC_INFO << QT_ENDL;
if (keepThisDataForNextQSOQcheckbox->isChecked())
{
//qDebug() << Q_FUNC_INFO << ": True" << QT_ENDL;
}
else
{
//qDebug() << Q_FUNC_INFO << ": False" << QT_ENDL;
}
slotSatNameComboBoxChanged();
}
void MainWindowSatTab::autofillSatMode()
{
//qDebug() << Q_FUNC_INFO ;
QString downLinkBand = bandToLetter(dataProxy->getBandNameFromFreq(rxFreqSpinBox->value()));
QString upLinkBand = bandToLetter(dataProxy->getBandNameFromFreq(txFreqSpinBox->value()));
satModeLineEdit->setText(upLinkBand + "/" + downLinkBand);
}
QString MainWindowSatTab::bandToLetter(const QString &_band)
{
//qDebug() << Q_FUNC_INFO << ": " << _band;
QString letter = "";
if (_band == "15M")
{
letter = "H";
}
else if (_band == "10M")
{
letter = "A";
}
else if (_band == "2M")
{
letter = "V";
}
else if (_band == "70CM")
{
letter = "U";
}
else if (_band == "23CM")
{
letter = "L";
}
else if (_band == "13CM")
{
letter = "S";
}
else if (_band == "5CM")
{
letter = "C";
}
else if (_band == "3CM")
{
letter = "X";
}
else if (_band == "1.25CM")
{
letter = "K";
}
else
{
letter = "-";
}
//qDebug() << Q_FUNC_INFO << ": " << _band << " -> " << letter;
return letter;
}
void MainWindowSatTab::setKeep(const bool _b)
{
keepThisDataForNextQSOQcheckbox->setChecked (_b);
}
bool MainWindowSatTab::getKeep()
{
return keepThisDataForNextQSOQcheckbox->isChecked ();
}
bool MainWindowSatTab::getDarkMode()
{
if (satNameLineEdit->palette().color (QPalette::Base) == "#646464")
{
return true;
}
else
{
return false;
}
}
klog-1.8.6/awards.cpp 0000644 0001750 0001750 00000200414 14166020421 013424 0 ustar devel devel #include "awards.h"
/***************************************************************************
awards.cpp - description
-------------------
begin : nov 2011
copyright : (C) 2011 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
//#include
Awards::Awards(DataProxy_SQLite *dp, const QString &_parentFunction)
{
//qDebug() << "Awards::Awards- from: " << _parentFunction << QT_ENDL;
dataProxy = dp;
//QSqlDatabase db = QSqlDatabase::database("QSQLITE");
world = new World(dataProxy, Q_FUNC_INFO);
//qDebug() << "Awards::Awards - Before DXMarathon" << QT_ENDL;
dxMarathon = new DXMarathon(dataProxy);
//qDebug() << "Awards::Awards - After DXMarathon" << QT_ENDL;
util = new Utilities();
//world->create();
/*
newOneColor.setNamedColor("#ff0000");
neededColor.setNamedColor("#ff8c00");
workedColor.setNamedColor("#ffd700");
confirmedColor.setNamedColor("#32cd32");
defaultColor.setNamedColor("#00bfff");
*/
//"Awards::setColors: " << _newOne << "/" << _needed << "/" << _worked << "/" << _confirmed << "/" << _default << QT_ENDL;
//Awards::setColors: "#ff0000" / "#ff8c00" / "#ffd700" / "#32cd32" / "#00bfff"
newOneColor = Qt::black;
neededColor = Qt::black;
workedColor = Qt::black;
confirmedColor = Qt::black;
defaultColor = Qt::black;
dxccWorked.clear();
dxccConfirmed.clear();
wazWorked.clear();
wazConfirmed.clear();
manageModes = false;
//qDebug() << "Awards::Awards - END" << QT_ENDL;
}
Awards::~Awards()
{
delete(world);
delete(dxMarathon);
delete(util);
}
void Awards::setAwardDXCC(const int _qsoId)
{
//qDebug() << "Awards::setAwardDXCC: _qsoId: " << QString::number(_qsoId) << QT_ENDL;
dataProxy->setDXCCAwardStatus(_qsoId);
}
void Awards::setAwardWAZ(const int _qsoId)
{
//qDebug() << "Awards::setAwardWAZ: _qsoId: " << QString::number(_qsoId) << QT_ENDL;
dataProxy->setWAZAwardStatus(_qsoId);
}
QString Awards::getQSOofAward (const int _enti, const int _bandid, const int _log, const bool _confirmed)
{// Returns the QRZ that granted that status in the DXCC
//qDebug() << "Awards::getQSOofAward: " << QString::number(_enti) << "/" << QString::number(_bandid) << QT_ENDL;
QSqlQuery query;
QString stringQuery = QString();
bool sqlOK = false;
QString answer = QString();
if (_confirmed)
{
stringQuery = QString("SELECT call, qso_date from log where dxcc='%1' AND bandid='%2' AND lognumber='%3' AND (qsl_rcvd='Y' OR lotw_qsl_rcvd='Y')").arg(_enti).arg(_bandid).arg(_log);
}
else
{
stringQuery = QString("SELECT call, qso_date from log where dxcc='%1' AND bandid='%2' AND lognumber='%3'").arg(_enti).arg(_bandid).arg(_log);
}
sqlOK = query.exec(stringQuery);
//qDebug() << "Awards::getQSOofAward: stringQuery: " << stringQuery << QT_ENDL;
if (sqlOK)
{
query.next();
if (query.isValid())
{
answer = query.value(0).toString() + " / " + query.value(1).toString() ;
query.finish();
//qDebug() << "Awards::getQSOofAward: answer: " << answer << QT_ENDL;
return answer;
}
else
{
query.finish();
//qDebug() << "Awards::getQSOofAward: 0" << QT_ENDL;
return QString();
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
//qDebug() << "Awards::getQSOofAward: Query error" << QT_ENDL;
return QString();
}
}
int Awards::getQSOIdofAward (const int _enti, const int _bandid, const int _log, const bool _confirmed)
{// Returns the QSOid that granted that status in the DXCC
//qDebug() << "Awards::getQSOIdofAward: " << QString::number(_enti) << "/" << QString::number(_bandid) << QT_ENDL;
QSqlQuery query;
QString stringQuery = QString();
bool sqlOK = false;
int answer = -1;
//stringQuery = QString("SELECT qsoid from awarddxcc where dxcc='%1' and band='%2'").arg(_enti).arg(_bandid);
if (_confirmed)
{
stringQuery = QString("SELECT id from log where dxcc='%1' AND bandid='%2' AND lognumber='%3' AND (qsl_rcvd='Y' OR lotw_qsl_rcvd='Y')").arg(_enti).arg(_bandid).arg(_log);
}
else
{
stringQuery = QString("SELECT id from log where dxcc='%1' AND bandid='%2' AND lognumber='%3'").arg(_enti).arg(_bandid).arg(_log);
}
sqlOK = query.exec(stringQuery);
//qDebug() << "Awards::getQSOIdofAward: stringQuery: " << stringQuery << QT_ENDL;
if (sqlOK)
{
query.next();
if (query.isValid())
{
answer = query.value(0).toInt();
//qDebug() << "Awards::getQSOIdofAward: answer: " << QString::number(answer) << QT_ENDL;
query.finish();
if (answer>=1)
{
return answer;
}
else
{
return -1;
}
}
else
{
query.finish();
//qDebug() << "Awards::getQSOIdofAward: 0" << QT_ENDL;
return -2;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
//qDebug() << "Awards::getQSOIdofAward: Query error" << QT_ENDL;
return -3;
}
}
int Awards::getDXCCWorked(const int _logNumber)
{
//qDebug() << "Awards::getDXCCWorked (logNumber): " << QString::number(_logNumber) << QT_ENDL;
QSqlQuery query;
QString stringQuery;
bool sqlOK;
if (dataProxy->doesThisLogExist(_logNumber))
{
stringQuery = QString("SELECT COUNT (DISTINCT dxcc) FROM log WHERE dxcc>'0' AND dxcc < '1000' AND lognumber='%1'").arg(_logNumber);
}
else
{
stringQuery = QString("SELECT COUNT (DISTINCT dxcc) FROM log WHERE dxcc>'0' AND dxcc < '1000' ");
}
sqlOK = query.exec(stringQuery);
//qDebug() << "Awards::getDXCCWorked: stringQuery: " << stringQuery << QT_ENDL;
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
//qDebug() << "Awards::getDXCCWorked: " << QString::number((query.value(0)).toInt()) << QT_ENDL;
return v;
}
else
{
//qDebug() << "Awards::getDXCCWorked: 0" << QT_ENDL;
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
//qDebug() << "Awards::getDXCCWorked: Query error" << QT_ENDL;
return 0;
}
}
int Awards::getDXCCConfirmed(const int _logNumber)
{
//qDebug() << "Awards::getDXCCConfirmed (logNumber): " << QString::number(_logNumber) << QT_ENDL;
return dataProxy->getFieldInBand (DXCC, "ALL", true, "ALL", _logNumber);
}
int Awards::getWAZWorked(const int _logNumber)
{
//qDebug() << "Awards::getWAZWorked (logNumber): " << QString::number(_logNumber) << QT_ENDL;
QSqlQuery query;
QString stringQuery;
if (dataProxy->doesThisLogExist(_logNumber))
{
stringQuery = QString("SELECT COUNT (cqz) FROM (SELECT DISTINCT cqz FROM log WHERE cqz!='' AND cqz>'0' AND cqz<'41' AND lognumber='%1')").arg(_logNumber);
}
else
{
stringQuery = QString("SELECT COUNT (cqz) FROM (SELECT DISTINCT cqz FROM log WHERE cqz!='' AND cqz>'0' AND cqz<'41')");
}
bool sqlOK = query.exec(stringQuery);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
return v;
}
else
{
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return 0;
}
}
int Awards::getWAZConfirmed(const int _logNumber)
{
//qDebug() << "Awards::getWAZConfirmed (logNumber): " << QString::number(_logNumber) << QT_ENDL;
QSqlQuery query;
QString stringQuery;
//Usar la siguiente para el confirmed
if (dataProxy->doesThisLogExist(_logNumber))
{
stringQuery = QString("SELECT COUNT (cqz) FROM (SELECT DISTINCT cqz FROM log WHERE cqz!='' AND cqz>'0' AND cqz<'41' AND (qsl_rcvd='Y' OR lotw_qsl_rcvd='Y') AND lognumber='%1')").arg(_logNumber);
}
else
{
stringQuery = QString("SELECT COUNT (cqz) FROM (SELECT DISTINCT cqz FROM log WHERE cqz!='' AND cqz>'0' AND cqz<'41' AND (qsl_rcvd='Y' OR lotw_qsl_rcvd='Y'))");
}
bool sqlOK = query.exec(stringQuery);
if (sqlOK)
{
query.next();
if (query.isValid())
{
int v =(query.value(0)).toInt();
query.finish();
return v;
}
else
{
return 0;
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return 0;
}
}
bool Awards::isThisSpotConfirmed(const QStringList &_qs)
{
return (getDXStatus(_qs) == 13);
}
int Awards::getDXStatus (const QStringList &_qs)
{
//qDebug() << "Awards::getDXStatus: Entity: " << _qs.at(0) << "/ Band: " << _qs.at(1) << "/ Mode: " << _qs.at(2) << "/ Log: " << _qs.at(3) << QT_ENDL;
// Receives: QStringList _qs;
//_qs << Entity << BandId << << ModeId << lognumber;
/* Not mode
-1 - Error. - ERROR - ERROR
0 - New one - New One - New One - 0
1 - Worked but not in this band nor this mode - Needed One - Needed One - 1
2 - Worked in this band, not this mode - Needed One - Worked One - 3
3 - Worked in this band and in this mode - Worked One - Worked One - 3
4 - Worked in this mode, not this band - Needed One - Needed One - 1
5 - Confirmed in another band/mode but not worked in this band nor this mode - Needed One - Needed One - 1
6 - Confirmed in another band/mode but just worked in this band and not in this mode - Needed One - Worked One - 3
7 - Confirmed in another band/mode but just worked in this mode and not in this band - Needed One - Needed One - 1
8 - Confirmed in another band/mode but just worked in this band and mode - Worked One - Worked One - 3
9 - Confirmed in this mode, but not worked this band - Needed One - Needed One - 1
10 - Confirmed in this mode, but worked this band - Worked One - Worked One - 3
11 - Confirmed in this band but not worked in this mode - Needed One - Confirmed One - 13
12 - Confirmed in this band but worked in this mode - Worked One - Confirmed One - 13
13 - Confirmed in this band and mode - Confirmed One - Confirmed One - 13
14 - New CQ Zone
15 - New CQ Zone on band
16 - New ITU Zone
17 - New ITU Zone on band
18 - New Grid
19 - New Grid on band
*/
/*
0 - New One - Never worked before - RED
1 - Needed - New one in this band - ORANGE
2 - Worked - Worked in this band but not confirmed - YELLOW
3 - Confirmed - Confirmed in this band - GREEN
*/
if (_qs.length() != 4 )
{
//qDebug() << "Awards::getDXStatus: Length != 4, return -1" << QT_ENDL;
return -1;
}
//int errorCode = 0;
int _band = _qs.at(1).toInt();
int _mode = _qs.at(2).toInt();
int _logNumber = _qs.at(3).toInt();
int dxccEntity = (_qs.at(0)).toInt();
//qDebug() << "Awards::getDXStatus: dxccEntity: " << QString::number(dxccEntity) << QT_ENDL;
if (dxccEntity<=0)
{
//qDebug() << "Awards::getDXStatus: dxccEntity <= 0, return -1" << QT_ENDL;
return -1;
}
bool checkingMode = true;
if ( (_mode==-1) || (manageModes==false))
{
checkingMode = false;
//qDebug() << "Awards::getDXStatus: checkingMode = FALSE" << QT_ENDL;
}
int wb = dxccStatusBand(dxccEntity, _band, _logNumber); //-1 error / 0 Not worked / 1 worked / 2 confirmed
int wm = -1;
if (checkingMode)
{
wm = dxccStatusMode(dxccEntity, _mode, _logNumber); //-1 error / 0 Not worked / 1 worked / 2 confirmed
}
// int wm = dxccStatusMode(dxccEntity, _mode, _logNumber); //-1 error / 0 Not worked / 1 worked / 2 confirmed
if (wm==-1)
{
checkingMode = false;
}
//qDebug() << "Awards::getDXStatus: wb=" << QString::number(wb) << " - wm=" << QString::number(wm) << QT_ENDL;
//qDebug() << "Awards::getDXStatus: dxccStatus: " << QString::number(dxccStatus(dxccEntity, _logNumber)) << QT_ENDL;
switch(dxccStatus(dxccEntity, _logNumber))
{
case 0:
//qDebug() << "Awards::getDXStatus: return 0" << QT_ENDL;
return 0; // ATNO
//break;
case 1: // Worked, not confirmed
switch (wb)
{
case 0: // Not worked in this band but in another band
if (checkingMode)
{
if (wm==1)
{
//qDebug() << "Awards::getDXStatus: return 4" << QT_ENDL;
return 4;
}
else
{
//qDebug() << "Awards::getDXStatus: return 1" << QT_ENDL;
return 1;
}
}
else
{
//qDebug() << "Awards::getDXStatus: return 4 nc" << QT_ENDL;
return 4;
}
case 1: // Worked in this band
if (checkingMode)
{
if (wm==1)
{
//qDebug() << "Awards::getDXStatus: return 3" << QT_ENDL;
return 3;
}
else
{
//qDebug() << "Awards::getDXStatus: return 2" << QT_ENDL;
return 2;
}
}
else
{
//qDebug() << "Awards::getDXStatus: return 3 nc" << QT_ENDL;
return 3;
}
default: // ERROR
//qDebug() << "Awards::getDXStatus: default return -1 - 1" << QT_ENDL;
return -1;
}
case 2: // Confirmed
if (wb==2)
{
if (checkingMode)
{
if (wm==2)
{
//qDebug() << "Awards::getDXStatus: return 13" << QT_ENDL;
return 13;
}
else if (wm==1)
{
//qDebug() << "Awards::getDXStatus: return 12" << QT_ENDL;
return 12;
}
else
{
//qDebug() << "Awards::getDXStatus: return 11" << QT_ENDL;
return 11;
}
}
else
{
//qDebug() << "Awards::getDXStatus: return 13 nc" << QT_ENDL;
return 13;
}
}
else if ((wb ==1) || (wb == 0))
{
if (checkingMode)
{
if (wb==1)
{
if (wm==1)
{
//qDebug() << "Awards::getDXStatus: return 8" << QT_ENDL;
return 8;
}
else
{
//qDebug() << "Awards::getDXStatus: return 6" << QT_ENDL;
return 6;
}
}
else
{
if (wm==1)
{
//qDebug() << "Awards::getDXStatus: return 7" << QT_ENDL;
return 7;
}
else
{
//qDebug() << "Awards::getDXStatus: return 5" << QT_ENDL;
return 5;
}
}
}
else
{
if (wb==0)
{
//qDebug() << "Awards::getDXStatus: return 7 nc" << QT_ENDL;
return 7;
}
else
{
//qDebug() << "Awards::getDXStatus: return 8 nc" << QT_ENDL;
return 8;
}
}
}
else
{
//qDebug() << "Awards::getDXStatus: return -1 - 2" << QT_ENDL;
return -1;
}
default:
//qDebug() << "Awards::getDXStatus: return -1 default2" << QT_ENDL;
return -1;
} // END OF SWITCH
//qDebug() << "Awards::getDXStatus: END, return -1" << QT_ENDL;
//return -1;
}
int Awards::dxccStatusBandMode(const int _ent, const int _band, const int _mode, const int _logNumber, bool _checkingMode)
{//-1 error / 0 Not worked / 1 worked / 2 confirmed
//qDebug() << "Awards::dxccStatusBandMode: " << QString::number(_ent) << "/" << QString::number(_band) << "/" << QString::number(_mode) << QT_ENDL;
QSqlQuery query = QSqlQuery();
QString queryString = QString();
if (_checkingMode)
{
//qDebug() << "Awards::dxccStatusBandMode: Checking Mode TRUE" << QT_ENDL;
queryString = QString("SELECT DISTINCT qsl_rcvd, lotw_qsl_rcvd FROM log WHERE dxcc='%1' AND bandid='%2' AND modeid='%3' AND lognumber='%4' ").arg(QString::number(_ent)).arg(QString::number(_band)).arg(QString::number(_mode)).arg(QString::number(_logNumber));
}
else
{
//qDebug() << "Awards::dxccStatusBandMode: Checking Mode FALSE" << QT_ENDL;
queryString = QString("SELECT DISTINCT qsl_rcvd, lotw_qsl_rcvd FROM log WHERE dxcc='%1' AND bandid='%2' AND lognumber='%3' ").arg(QString::number(_ent)).arg(QString::number(_band)).arg(QString::number(_logNumber));
}
int status = 0;
if (query.exec(queryString))
{
while (query.next())
{
if ( query.isValid() )
{
if((query.value(0).toString() == "Y") || (query.value(1).toString() == "Y"))
{
//qDebug() << "Awards::dxccStatusBandMode: return - 2" << QT_ENDL;
query.finish();
return 2;
}
status = 1;
}
}
query.finish();
}
else
{ // The query fails...
//qDebug() << "Awards::dxccStatusBandMode: return - -1" << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
//qDebug() << "Awards::dxccStatusBandMode: return - 0-4" << QT_ENDL;
return status;
}
/*
int Awards::dxccStatusBandMode(const int _ent, const int _band, const int _mode, const int _logNumber, bool _checkingMode)
{//-1 error / 0 Not worked / 1 worked / 2 confirmed
//qDebug() << "Awards::dxccStatusBandMode: " << QString::number(_ent) << "/" << QString::number(_band) << "/" << QString::number(_mode) << QT_ENDL;
QSqlQuery query = QSqlQuery();
QString queryString = QString();
if (_checkingMode)
{
//qDebug() << "Awards::dxccStatusBandMode: Checking Mode TRUE" << QT_ENDL;
queryString = QString("SELECT confirmed FROM awarddxcc WHERE dxcc='%1' AND band='%2' AND mode='%3' AND lognumber='%4' ").arg(QString::number(_ent)).arg(QString::number(_band)).arg(QString::number(_mode)).arg(QString::number(_logNumber));
}
else
{
//qDebug() << "Awards::dxccStatusBandMode: Checking Mode FALSE" << QT_ENDL;
queryString = QString("SELECT confirmed FROM awarddxcc WHERE dxcc='%1' AND band='%2' AND lognumber='%3' ").arg(QString::number(_ent)).arg(QString::number(_band)).arg(QString::number(_logNumber));
}
int status = 0;
if (query.exec(queryString))
{
while (query.next())
{
if ( query.isValid() )
{
if(query.value(0).toString() == "1")
{
//qDebug() << "Awards::dxccStatusBandMode: return - 2" << QT_ENDL;
query.finish();
return 2;
}
else if(query.value(0).toString() == "0")
{
//qDebug() << "Awards::dxccStatusBandMode: return - 1" << QT_ENDL;
if (status < 1)
{
status = 1;
}
}
}
}
query.finish();
}
else
{ // The query fails...
//qDebug() << "Awards::dxccStatusBandMode: return - -1" << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
//qDebug() << "Awards::dxccStatusBandMode: return - 0-4" << QT_ENDL;
return status;
}
*/
int Awards::dxccStatus(const int _ent, const int _logNumber)
{//-1 error / 0 Not worked / 1 worked / 2 confirmed
//qDebug() << "Awards::dxccStatus: " << QString::number(_ent) << QT_ENDL;
QSqlQuery query = QSqlQuery();
QString queryString = QString();
int worked = 0;
queryString = QString("SELECT DISTINCT qsl_rcvd, lotw_qsl_rcvd FROM log WHERE dxcc='%1' AND lognumber='%2' ").arg(QString::number(_ent)).arg(QString::number(_logNumber));
if (query.exec(queryString))
{
//qDebug() << "Awards::dxccStatus: query exec OK: " << query.lastQuery() << QT_ENDL;
while (query.next())
{
//qDebug() << "Awards::dxccStatus: query VALUE: " << (query.value(0)).toString() << QT_ENDL;
if ( query.isValid() )
{
//qDebug() << "Awards::dxccStatus: query valid OK" << QT_ENDL;
if(((query.value(0)).toString() == "Y") || ((query.value(1)).toString() == "Y"))
{
//qDebug() << "Awards::dxccStatus: value = 1 - return 2" << QT_ENDL;
query.finish();
return 2;
}
worked = 1;
}
}
//qDebug() << "Awards::dxccStatus: return "<< QString::number(worked) << QT_ENDL;
query.finish();
//qDebug() << "Awards::dxccStatus: END: " << QString::number(worked) << QT_ENDL;
return worked;
}
else
{ // The query fails...
//qDebug() << "Awards::dxccStatus: return -1" << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
//qDebug() << "Awards::dxccStatus: return 0" << QT_ENDL;
//return worked;
}
/*
int Awards::dxccStatus(const int _ent, const int _logNumber)
{//-1 error / 0 Not worked / 1 worked / 2 confirmed
//qDebug() << "Awards::dxccStatus: " << QString::number(_ent) << QT_ENDL;
QSqlQuery query = QSqlQuery();
QString queryString = QString();
int worked = 0;
queryString = QString("SELECT confirmed FROM awarddxcc WHERE dxcc='%1' AND lognumber='%2' ").arg(QString::number(_ent)).arg(QString::number(_logNumber));
if (query.exec(queryString))
{
//qDebug() << "Awards::dxccStatus: query exec OK: " << query.lastQuery() << QT_ENDL;
while (query.next())
{
//qDebug() << "Awards::dxccStatus: query VALUE: " << (query.value(0)).toString() << QT_ENDL;
if ( query.isValid() )
{
//qDebug() << "Awards::dxccStatus: query valid OK" << QT_ENDL;
if((query.value(0)).toString() == "1")
{
//qDebug() << "Awards::dxccStatus: value = 1 - return 2" << QT_ENDL;
query.finish();
return 2;
}
else if((query.value(0)).toString() == "0")
{
//qDebug() << "Awards::dxccStatus: value = 0 - worked 1" << QT_ENDL;
if (worked <1)
{
worked = 1;
}
}
}
}
//qDebug() << "Awards::dxccStatus: return "<< QString::number(worked) << QT_ENDL;
query.finish();
//qDebug() << "Awards::dxccStatus: END: " << QString::number(worked) << QT_ENDL;
return worked;
}
else
{ // The query fails...
//qDebug() << "Awards::dxccStatus: return -1" << QT_ENDL;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
//qDebug() << "Awards::dxccStatus: return 0" << QT_ENDL;
//return worked;
}
*/
QColor Awards::getQRZDXStatusColor(const QStringList &_qs)
{
//qs << Entity << spotBand << "-1" << QString::number(currentLog) ;
//qDebug() << "Awards::getQRZDXStatusColor qs.length: " << QString::number(_qs.length()) << QT_ENDL;
//From Search QSO to QSL: q << _call << bandid << _mode << QString::number(currentLog);
//qDebug() << "Awards::getQRZDXStatusColor: " << _qs.at(0) << "/" << _qs.at(1) << "/" << _qs.at(2) << _qs.at(3) << QT_ENDL;
// Receives: QStringList _qs;
//_qs << Entity << BandID << ModeId << lognumber;
/*
0 - New One
1 - Needed
2 - Worked
3 - Confirmed
*/
QColor returnedColor;
int status = getDXStatus(_qs);
//qDebug() << "Awards::getQRZDXStatusColor: status: " << QString::number(status) << "/" << getDXStatusString(status) << QT_ENDL;
//qDebug() << "Awards::getQRZDXStatusColor: status: " << QString::number(status) << QT_ENDL;
switch (status) {
case 0:
returnedColor = newOneColor;
break;
case 1:
returnedColor = neededColor;
break;
case 2:
returnedColor = neededColor;
break;
case 3:
returnedColor = workedColor;
break;
case 4:
returnedColor = neededColor;
break;
case 5:
returnedColor = neededColor;
break;
case 6:
returnedColor = neededColor;
break;
case 7:
returnedColor = neededColor;
break;
case 8:
returnedColor = workedColor;
break;
case 9:
returnedColor = neededColor;
break;
case 10:
returnedColor = workedColor;
break;
case 11:
returnedColor = neededColor;
break;
case 12:
returnedColor = workedColor;
break;
case 13:
returnedColor = confirmedColor;
break;
//break;
default:
returnedColor = defaultColor;
break;
}
return returnedColor;
}
QString Awards::getDXStatusString (const int &_status)
{
//qDebug() << "Awards::getDXStatusString: " << QString::number(_status) << QT_ENDL;
QString message = QString();
switch (_status) {
case 0:
message = QObject::tr("New One, work it!");
//message = QObject::tr("0-new One");
break;
case 1:
message = QObject::tr("Needed, work it!");
//message = QObject::tr("1-Needed, work it!");
break;
case 2:
message = QObject::tr("Needed, work it!");
break;
case 3:
message = QObject::tr("Worked but not confirmed");
break;
case 4:
message = QObject::tr("Needed, work it!");
break;
case 5:
message = QObject::tr("Needed, work it!");
break;
case 6:
message = QObject::tr("Needed, work it!");
break;
case 7:
message = QObject::tr("Needed, work it!");
break;
case 8:
message = QObject::tr("Worked but not confirmed");
break;
case 9:
message = QObject::tr("Needed, work it!");
break;
case 10:
message = QObject::tr("Worked but not confirmed");
break;
case 11:
message = QObject::tr("Needed, work it!");
break;
case 12:
message = QObject::tr("Worked but not confirmed");
break;
case 13:
message = QObject::tr("Confirmed");
break;
//break;
default:
message = QObject::tr("Not identified");
break;
}
return message;
}
QString Awards::getDXCCStatusBand(const int _dxcc, const int _band)
{
// Returns -, W or C (Not worked, worked, Confirmed)
//qDebug() << Q_FUNC_INFO << "DXCC/Band: " << QString::number(_dxcc) << "/" << QString::number(_band);
//qDebug() << Q_FUNC_INFO << "dxccStatusList: " << QString::number(dxccStatusList.length ());
EntityBandStatus aux;
foreach (aux, dxccStatusList)
{
//qDebug() << Q_FUNC_INFO << " DXCC: " << QString::number(aux.dxcc);
//qDebug() << Q_FUNC_INFO << " Band: " << QString::number(aux.bandid);
if (aux.confirmed)
{
//qDebug() << Q_FUNC_INFO << "Confirmed";
}
else
{
//qDebug() << Q_FUNC_INFO << "Not confirmed";
}
if (aux.dxcc == _dxcc)
{
//qDebug() << Q_FUNC_INFO << " DXCC found: " << QString::number(_dxcc);
if (aux.bandid == _band)
{
//qDebug() << Q_FUNC_INFO << " Band found: " << QString::number(_band);
if (aux.confirmed)
{
//qDebug() << Q_FUNC_INFO << " Confirmed " ;
return "C";
}
else
{
//qDebug() << Q_FUNC_INFO << " Worked " ;
return "W";
}
}
}
}
//qDebug() << Q_FUNC_INFO << " Returnin -" ;
return "-";
}
QString Awards::getDXCCStatusBand2(const int _dxcc, const int _band, const int _logNumber)
{
// Returns -, W or C (Not worked, worked, Confirmed)
//qDebug() << "Awards::getDXCCStatusBand: log received: " << QString::number(_logNumber) << QT_ENDL;
QString stringQuery;
if (_logNumber<0)
{
stringQuery = QString("SELECT DISTINCT qsl_rcvd, lotw_qsl_rcvd FROM log WHERE dxcc='%1' AND bandid='%2'").arg(_dxcc).arg(_band);
}
else
{
stringQuery = QString("SELECT DISTINCT qsl_rcvd, lotw_qsl_rcvd FROM log WHERE dxcc='%1' AND bandid='%2' AND lognumber='%3'").arg(_dxcc).arg(_band).arg(_logNumber);
}
QString status = "-";
QSqlQuery query;
bool sqlOk = query.exec(stringQuery);
if (sqlOk)
{
while (query.next()) {
if (query.isValid())
{
if (((query.value(0)).toString() == "Y") || ((query.value(1)).toString() == "Y"))
{
query.finish();
return "C";
}
status = "W";
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return "-";
}
query.finish();
return status;
}
/*
QString Awards::getDXCCStatusBand(const int _dxcc, const int _band, const int _logNumber)
{
// Returns -, W or C (Not worked, worked, Confirmed)
//qDebug() << "Awards::getDXCCStatusBand: log received: " << QString::number(_logNumber) << QT_ENDL;
QString stringQuery;
if (_logNumber<0)
{
stringQuery = QString("SELECT confirmed from awarddxcc WHERE dxcc='%1' AND band='%2'").arg(_dxcc).arg(_band);
}
else
{
stringQuery = QString("SELECT confirmed from awarddxcc WHERE dxcc='%1' AND band='%2' AND lognumber='%3'").arg(_dxcc).arg(_band).arg(_logNumber);
}
QString status = "-";
QSqlQuery query;
bool sqlOk = query.exec(stringQuery);
if (sqlOk)
{
while (query.next()) {
if (query.isValid())
{
if ((query.value(0)).toString() == "1")
{
query.finish();
return "C";
}
else if ((query.value(0)).toString() == "0")
{
if (status == "-")
{
status = "W";
}
}
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return "-";
}
query.finish();
return status;
}
*/
QString Awards::checkIfValidIOTA(const QString &_tiota)
{
/**********************************
IOTA should be always with this format: CC-NNN
being:
- CC the shortname of the continent
- NNN Number of the reference.
NNN has ALWAYS to include THREE(3) characters.
ADIF Specs says:
CC is the continent designator {NA, SA, EU , AF, OC, AS, AN}
XXX is the island designator, where 0 <= XXX ,<= 999 [use leading zeroes]
Returns a valid format IOTA if possible and "" in other cases.
************************************/
//qDebug() << "Awards::checkIfValidIOTA: " << _tiota << QT_ENDL;
//bool _valid = false;
QString _continent;
QString _number;
if (_tiota.count("-") == 1)
{
QStringList _values = _tiota.split("-", QT_SKIP);
if (_values.size() != 2)
{
return "";
}
if (dataProxy->isValidContinentShortName(_values.at(0)))
{
_continent = _values.at(0);
}
else
{
return "";
}
if ((_values.at(1)).toInt() > 0)
{
_number = _values.at(1);
}
else
{
return "";
}
}
else
{
return "";
}
//qDebug() << "Awards::checkIfValidIOTA (cont) " << _continent << QT_ENDL;
//qDebug() << "Awards::checkIfValidIOTA (numb): " << _number << QT_ENDL;
// Check if continent is valid
if (dataProxy->isValidContinentShortName(_continent))
{
if ( (_number.toInt() >0 ) && ((_number.toInt()) < 1000 ))
{
if ((_number.length()) == 3)
{
return _continent + "-" + _number ;
}
else if ((_number.length()) == 2)
{
return _continent + "-0" + QString::number((_number).toInt());
}
else if ((_number.length()) == 1)
{
return _continent + "-00" + QString::number((_number).toInt());
}
else
{
return "";
}
}
else
{
return "";
}
}
else
{
return QString();
}
//return QString();
/*
QString stringQuery = QString("SELECT id FROM continent WHERE shortname ='%1'").arg(_continent);
QSqlQuery query;
query.exec(stringQuery);
while (query.next()) {
if (query.isValid())
{
_valid = true;
if ( (_number.toInt() >0 ) && ((_number.toInt()) < 1000 ))
{
if ((_number.length()) == 3)
{
return _continent + "-" + _number ;
}
else if ((_number.length()) == 2)
{
return _continent + "-0" + QString::number((_number).toInt());
}
else if ((_number.length()) == 1)
{
return _continent + "-00" + QString::number((_number).toInt());
}
else
{
return "";
}
}
else
{
return "";
}
}
}
return "";
*/
}
void Awards::setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default)
{
//qDebug() << "Awards::setColors: " << _newOne << "/" << _needed << "/" << _worked << "/" << _confirmed << "/" << _default << QT_ENDL;
defaultColor = QColor(_default.toUpper());
neededColor = QColor(_needed.toUpper());
workedColor = QColor(_worked.toUpper());
confirmedColor = QColor(_confirmed.toUpper());
newOneColor = QColor(_newOne.toUpper());
if (defaultColor.isValid())
{
defaultColor.setNamedColor(_default.toUpper());
}
if (neededColor.isValid())
{
neededColor.setNamedColor(_needed.toUpper());
}
if (confirmedColor.isValid())
{
confirmedColor.setNamedColor(_confirmed.toUpper());
}
if (newOneColor.isValid())
{
newOneColor.setNamedColor(_newOne.toUpper());
}
if (workedColor.isValid())
{
workedColor.setNamedColor(_worked.toUpper());
}
}
QColor Awards::getDefaultColor()
{
return defaultColor;
}
void Awards::recalculateAwards()
{
/*
TODO: I need to optimize this function.
The select & insert of setAwardDXCC are too slow)
Should go in a transaction
*/
//qDebug() << "Awards::recalculateAwards" << QT_ENDL;
dataProxy->updateAwardDXCC();
emit awardDXCCUpdated();
dataProxy->updateAwardWAZ();
//qDebug() << "Awards::recalculateAwards - END" << QT_ENDL;
}
int Awards::getQSOsInLog(const int _logNumber)
{
//qDebug() << "Awards::getQSOsInLog: " << QString::number(_logNumber) << QT_ENDL;
QSqlQuery query;
QString queryString;
int v;
queryString = QString("SELECT COUNT (id) FROM log WHERE lognumber='%1'").arg(_logNumber) ;
if( !query.exec(queryString) )
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
else
{
query.next();
if (query.isValid())
{
v = query.value(0).toInt();
query.finish();
return v;
}
else
{
query.finish();
return -2;
}
}
}
/*
void Awards::setAwards(const int _dxcc, const int _waz, const int _band, const int _mode, const int _workedOrConfirmed, const int _logNumber, const int _qsoId)
{
//qDebug() << "Awards::setAwards: " << QString::number(_dxcc) << QT_ENDL;
//_workedOrConfirmed = -1 Remove this pair
//_workedOrConfirmed = 0 Set as Worked
//_workedOrConfirmed = 1 Set as Confirmed
int d = _dxcc;
int b = _band;
int m = _mode;
int w = _workedOrConfirmed;
int l = _logNumber;
int i = _qsoId;
int z = _waz;
setAwardDXCC(d, b, m, w, l, i);
setAwardWAZ(z, b, m, w, l, i);
//setAwardWAZ(_waz, _band, _mode, _workedOrConfirmed, _logNumber);
}
*/
void Awards::setAwards(const int _qsoId)
{
//qDebug() << "Awards::setAwards: _qsoId: " << QString::number(_qsoId) << QT_ENDL;
dataProxy->setDXCCAwardStatus(_qsoId);
dataProxy->setWAZAwardStatus(_qsoId);
}
/*
int Awards::setAwardDXCCst(const int _dxcc, const int _band, const int _mode, const bool _confirmed, const int _logNumber, const int _qsoId)
{
//qDebug() << "Awards::setAwardDXCCst-0: " << QString::number(_dxcc) << "/" << QString::number(_band) << "/" << QString::number(_mode) << "/" << QString::number(_logNumber) << "/" << QString::number(_qsoId) << QT_ENDL;
int nameCol=-1;
QString _refid = QString();
// _confirmedQSO == false QSO is just worked
// _confirmedQSO == true QSO is confirmed
//TODO: Fix the way we check for data validity for this function
if (!( (_dxcc>=0) && (_band >=0) && (_mode>=0) && (_logNumber>=0) && (_qsoId >=0) ))
{
//qDebug() << "Awards::setAwardDXCCst: Not valid data received!" << QT_ENDL;
return -1;
}
int _iconfirmed;
if (_confirmed)
{
_iconfirmed = 1;
}
else
{
_iconfirmed = 0;
}
//qDebug() << "Awards::setAwardDXCCst: _qsoId: " << QString::number(_qsoId) << "/" << QString::number(_iconfirmed) << QT_ENDL;
QString stringQuery = QString();
QSqlQuery query;
bool sqlOK = false;
int errorCode = -1;
stringQuery = QString("SELECT id, confirmed FROM awarddxcc where dxcc='%1' AND band='%2' AND mode='%3' AND lognumber='%4'").arg(_dxcc).arg(_band).arg(_mode).arg(_logNumber);
sqlOK = query.exec(stringQuery);
if (sqlOK)
{
//qDebug() << "Awards::setAwardDXCCst-1:" << QT_ENDL;
query.next();
QSqlRecord rec = query.record();
if (query.isValid())
{// We have some data, we need to UPDATE - We are only confirming!
//qDebug() << "Awards::setAwardDXCCst: We have some data, we neer to update" << QT_ENDL;
nameCol = rec.indexOf("id");
_refid = query.value(nameCol).toString();
stringQuery = QString("UPDATE awarddxcc SET confirmed='1', qsoid='%1' WHERE id='%2'").arg(_qsoId).arg(_refid);
//qDebug() << "Awards::setAwardDXCCst: (UPDATE): " << stringQuery << QT_ENDL;
if (sqlOK)
{ // Set of data updated
//qDebug() << "Awards::setAwardDXCCst: Data updated!" << QT_ENDL;
query.finish();
return 1;
}
else
{ // Something failed. Trace it!
errorCode = query.lastError().nativeErrorCode();
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
}
else
{ // We don't have this set, we need to INSERT
stringQuery = QString("INSERT INTO awarddxcc (dxcc, band, mode, confirmed, lognumber, qsoid) values('%1','%2','%3','%4','%5','%6')").arg(_dxcc).arg(_band).arg(_mode).arg(_iconfirmed).arg(_logNumber).arg(_qsoId);
sqlOK = query.exec(stringQuery);
//qDebug() << "Awards::setAwardDXCCst: We don't have data... so we INSERT" << QT_ENDL;
//qDebug() << "Awards::setAwardDXCCst: (INSERT): " << stringQuery << QT_ENDL;
if (sqlOK)
{ // Set of data included
query.finish();
//qDebug() << "Awards::setAwardDXCCst: Data inserted!" << QT_ENDL;
}
else
{ // Something failed. Trace it!
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
errorCode = query.lastError().nativeErrorCode();
query.finish();
return -1;
}
}
}
else
{ // Trace the error... what may be happening???
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
errorCode = query.lastError().nativeErrorCode();
query.finish();
return -1;
}
return -1;
}
*/
/*
int Awards::setAwardWAZst(const int _cqz, const int _band, const int _mode, const bool _confirmed, const int _logNumber, const int _qsoId)
{
//qDebug() << "Awards::setAwardWAZst(CQZ/BAND/MODE/WORKED/log/qsoid): " << QString::number(_cqz) << "/" << QString::number(_band) << "/" << QString::number(_mode) << "/" << QString::number(_logNumber) << "/" << QString::number(_qsoId) << QT_ENDL;
// _confirmed == false QSO is just worked
// _confirmed == true QSO is confirmed
//TODO: Fix the way we check for data validity for this function
if (!( (_cqz>=0) && (_band >=0) && (_mode>=0) && (_logNumber>=0) && (_qsoId >=0) ))
{
//qDebug() << "Awards::setAwardWAZst: some data was NOK" << QT_ENDL;
return -1;
}
int _iconfirmed;
if (_confirmed)
{
_iconfirmed = 1;
}
else
{
_iconfirmed = 0;
}
QString stringQuery;
QSqlQuery query;
bool sqlOK;
//int errorCode = -1;
stringQuery = QString("INSERT INTO awardwaz (cqz, band, mode, confirmed, lognumber, qsoid) values('%1','%2','%3','%4','%5','%6')").arg(_cqz).arg(_band).arg(_mode).arg(_iconfirmed).arg(_logNumber).arg(_qsoId);
sqlOK = query.exec(stringQuery);
if ((sqlOK) && (!_confirmed)) // First time a DXCC/Band/mode is worked
{
//qDebug() << "Awards::setAwardWAZst: _qsoId: " << QString::number(_qsoId) << "- 1" << QT_ENDL;
query.finish();
return 1;
}
else if ((sqlOK) && (_confirmed)) // First time a CQZ/Band/Mode is confirmed
{
//qDebug() << "Awards::setAwardWAZst: _qsoId: " << QString::number(_qsoId) << "- 2" << QT_ENDL;
query.finish();
return 2;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "Awards::setAwardWAZst: _qsoId: " << QString::number(_qsoId) << "- sqlOK ERROR: " << QT_ENDL;
//errorCode = query.lastError().nativeErrorCode();
query.finish();
//qDebug() << "Awards::setAwardWAZst: LastQuery: " << query.lastQuery() << QT_ENDL;
//qDebug() << "Awards::setAwardWAZst: LastError-data: " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << "Awards::setAwardWAZst: LastError-driver: " << query.lastError().driverText() << QT_ENDL;
//qDebug() << "Awards::setAwardWAZst: LastError-n: " << QString::number(query.lastError().nativeErrorCode() ) << QT_ENDL;
}
return -1;
}
*/
/*
int Awards::setAwardDXCCConfirmed(const int _band, const int _mode, const int _dxcc, const int _newQSOid) // Changes the status of a DXCC from worked to confirmed
{
//qDebug() << "Awards::setAwardDXCCConfirmed: " << QString::number(_band) << "/" << QString::number(_mode) << "/" << QString::number(_dxcc)<< "/" << QString::number(_newQSOid)<< QT_ENDL;
QString stringQuery;
QSqlQuery query = QSqlQuery();
bool sqlOK = false;
int errorCode = -1;
int nameCol = -1;
QString aux = QString();
stringQuery = QString("SELECT qsoid FROM awarddxcc WHERE band='%1' AND mode='%2' AND dxcc='%3'").arg(_band).arg(_mode).arg(_dxcc);
sqlOK = query.exec(stringQuery);
if (sqlOK)
{
QSqlRecord rec = query.record();
if (query.next())
{
if (query.isValid())
{
nameCol = rec.indexOf("qsoid");
aux = (query.value(nameCol)).toString();
query.finish();
stringQuery = QString("UPDATE awarddxcc SET confirmed='1', qsoid='%1' WHERE qsoid='%2'").arg(_newQSOid).arg(aux);
sqlOK = query.exec(stringQuery);
if (sqlOK)
{
query.finish();
return _newQSOid;
}
else
{ // UPDATE failed
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
errorCode = query.lastError().nativeErrorCode();
query.finish();
//qDebug() << "Awards::setAwardDXCCConfirmed-Update: LastQuery: " << query.lastQuery() << QT_ENDL;
//qDebug() << "Awards::setAwardDXCCConfirmed-Update: LastError-data: " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << "Awards::setAwardDXCCConfirmed-Update: LastError-driver: " << query.lastError().driverText() << QT_ENDL;
//qDebug() << "Awards::setAwardDXCCConfirmed-Update: LastError-n: " << QString::number(query.lastError().nativeErrorCode() ) << QT_ENDL;
return errorCode;
}
}
else
{
// Not valid record
//qDebug() << "Awards::setAwardDXCCConfirmed: Not valid record" << QT_ENDL;
return -3;
}
}
else
{
// Not next record
//qDebug() << "Awards::setAwardDXCCConfirmed: Not next record" << QT_ENDL;
return -2;
}
}
else
{ //
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
errorCode = query.lastError().nativeErrorCode();
query.finish();
//qDebug() << "Awards::setAwardDXCCConfirmed: LastQuery: " << query.lastQuery() << QT_ENDL;
//qDebug() << "Awards::setAwardDXCCConfirmed: LastError-data: " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << "Awards::setAwardDXCCConfirmed: LastError-driver: " << query.lastError().driverText() << QT_ENDL;
//qDebug() << "Awards::setAwardDXCCConfirmed: LastError-n: " << QString::number(query.lastError().nativeErrorCode() ) << QT_ENDL;
return errorCode;
}
return 1;
}
*/
int Awards::setDXCCToQSO(const int _dxcc, const int _qsoid) // Defines the DXCC in a QSO
{
//qDebug() << "Awards::setDXCCToQSO: " << QString::number(_dxcc) << "/" << QString::number(_qsoid) << QT_ENDL;
int errorCode = -1;
QString queryString = QString("UPDATE log SET dxcc='%1' WHERE id='%2'").arg(_dxcc).arg(_qsoid);
QSqlQuery query = QSqlQuery();
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.finish();
return 1;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "Awards::setDXCCToQSO: DXCC Updated in Log but failed...." << QT_ENDL;
errorCode = query.lastError().nativeErrorCode().toInt();
query.finish();
//qDebug() << "Awards::setDXCCToQSO: LastQuery: " << query.lastQuery() << QT_ENDL;
//qDebug() << "Awards::setDXCCToQSO: LastError-data: " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << "Awards::setDXCCToQSO: LastError-driver: " << query.lastError().driverText() << QT_ENDL;
//qDebug() << "Awards::setDXCCToQSO: LastError-n: " << QString::number(query.lastError().nativeErrorCode() ) << QT_ENDL;
return errorCode;
}
}
int Awards::setCQToQSO(const int _cqz, const int _qsoid) // Defines the CQ in a QSO
{
//qDebug() << "Awards::setCQToQSO: " << QString::number(_cqz) << "/" << QString::number(_qsoid) << QT_ENDL;
int errorCode = -1;
QString queryString = QString("UPDATE log SET cqz='%1' WHERE id='%2'").arg(_cqz).arg(_qsoid);
QSqlQuery query = QSqlQuery();
bool sqlOK = query.exec(queryString);
if (sqlOK)
{
query.finish();
return 1;
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << "Awards::setCQToQSO: DXCC Updated in Log but failed...." << QT_ENDL;
errorCode = query.lastError().nativeErrorCode().toInt();
query.finish();
//qDebug() << "Awards::setCQToQSO: LastQuery: " << query.lastQuery() << QT_ENDL;
//qDebug() << "Awards::setCQToQSO: LastError-data: " << query.lastError().databaseText() << QT_ENDL;
//qDebug() << "Awards::setCQToQSO: LastError-driver: " << query.lastError().driverText() << QT_ENDL;
//qDebug() << "Awards::setCQToQSO: LastError-n: " << QString::number(query.lastError().nativeErrorCode() ) << QT_ENDL;
return errorCode;
}
}
bool Awards::getIsDXCCConfirmed(const int _dxcc, const int _logNumber)
{
// isDXCCConfirmed(const int _dxcc, const int _currentLog);
return dataProxy->isDXCCConfirmed(_dxcc, _logNumber);
}
int Awards::getDXMarathonQSO(const int _year, const int _logNumber)
{
//qDebug() << "Awards::getDXMarathonQSO: " << QString::number(_year) << QT_ENDL;
return dxMarathon->getDXMarathonQSO(_year, _logNumber);
}
int Awards::getDXMarathonDXCC(const int _year, const int _logNumber)
{
//qDebug() << "Awards::getDXMarathonDXCC: " << QString::number(_year) << QT_ENDL;
return dxMarathon->getDXMarathonDXCC(_year, _logNumber);
}
int Awards::getDXMarathonCQ(const int _year, const int _logNumber)
{
//qDebug() << "Awards::getDXMarathonCQ: " << QString::number(_year) << QT_ENDL;
return dxMarathon->getDXMarathonCQ(_year, _logNumber);
}
int Awards::getDXMarathonScore(const int _year, const int _logNumber)
{
//qDebug() << "Awards::getDXMarathonScore: " << QString::number(_year) << QT_ENDL;
return dxMarathon->getDXMarathonScore(_year, _logNumber);
}
bool Awards::isDXMarathonNeed(const int _dxcc, const int _cq, const int _year, const int _logNumber)
{
return dxMarathon->neededForDXMarathon(_dxcc, _cq, _year, _logNumber);
}
int Awards::dxccStatusBand(const int _ent, const int _band, const int _logNumber) //-1 error / 0 Not worked / 1 worked / 2 confirmed
{
//-1 error / 0 Not worked / 1 worked / 2 confirmed
//qDebug() << "Awards::dxccStatusBand: " << QString::number(_ent) << "/" << QString::number(_band) << QT_ENDL;
QSqlQuery query = QSqlQuery();
QString queryString = QString("SELECT DISTINCT qsl_rcvd, lotw_qsl_rcvd FROM log WHERE dxcc='%1' AND qsl_rcvd='Y' AND bandid='%2' AND lognumber='%4' ").arg(QString::number(_ent)).arg(QString::number(_band)).arg(QString::number(_logNumber));
int status = 0;
//qDebug() << "Awards::dxccStatusBand: " << queryString << QT_ENDL;
if (query.exec(queryString))
{
while (query.next())
{
if ( query.isValid() )
{
if((query.value(0).toString() == "Y") || (query.value(1).toString() == "Y")) // Confirmed
{
query.finish();
return 2;
}
status = 1;
} // Not present => Not worked
}
query.finish();
}
else
{
//TODO: Manage the query error
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
//qDebug() << "Awards::dxccStatusBand: return - 0.3" << QT_ENDL;
return status; // if arrives to here decision => not worked
}
/*
int Awards::dxccStatusBand(const int _ent, const int _band, const int _logNumber) //-1 error / 0 Not worked / 1 worked / 2 confirmed
{
//-1 error / 0 Not worked / 1 worked / 2 confirmed
//qDebug() << "Awards::dxccStatusBand: " << QString::number(_ent) << "/" << QString::number(_band) << QT_ENDL;
QSqlQuery query = QSqlQuery();
QString queryString = QString();
queryString = QString("SELECT confirmed FROM awarddxcc WHERE dxcc='%1' AND band='%2' AND lognumber='%4' ").arg(QString::number(_ent)).arg(QString::number(_band)).arg(QString::number(_logNumber));
int status = 0;
if (query.exec(queryString))
{
while (query.next())
{
if ( query.isValid() )
{
if(query.value(0).toString() == "1") // Confirmed
{
query.finish();
return 2;
}
else if(query.value(0).toString() == "0") // Worked
{
if (status < 1)
{
status = 1;
}
}
} // Not present => Not worked
}
query.finish();
}
else
{
//TODO: Manage the query error
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return -1;
}
//qDebug() << "Awards::dxccStatusBand: return - 0.3" << QT_ENDL;
return status; // if arrives to here decision => not worked
}
*/
int Awards::dxccStatusMode(const int _ent, const int _mode, const int _logNumber) //-1 error / 0 Not worked / 1 worked / 2 confirmed
{
//-1 error / 0 Not worked / 1 worked / 2 confirmed
//qDebug() << "Awards::dxccStatusMode: " << QString::number(_ent) << "/" << QString::number(_mode) << QT_ENDL;
QSqlQuery query = QSqlQuery();
QString queryString = QString();
if (_mode == -1)
{
return -1;
}
int status = 0;
queryString = QString("SELECT DISTINCT qsl_rcvd, lotw_qsl_rcvd FROM log WHERE dxcc='%1' AND modeid='%2' AND lognumber='%4' ").arg(QString::number(_ent)).arg(QString::number(_mode)).arg(QString::number(_logNumber));
if (query.exec(queryString))
{
while (query.next())
{
if ( query.isValid() )
{
if((query.value(0).toString() == "Y") || (query.value(1).toString() == "Y")) // Confirmed
{
query.finish();
return 2;
}
status = 1;
} // Not present => Not worked
}
query.finish();
}
else
{ // The query fails...
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
//TODO: Manage the query error
return -1;
}
return status; // if arrives to here decision => not worked
}
/*
int Awards::dxccStatusMode(const int _ent, const int _mode, const int _logNumber) //-1 error / 0 Not worked / 1 worked / 2 confirmed
{
//-1 error / 0 Not worked / 1 worked / 2 confirmed
//qDebug() << "Awards::dxccStatusMode: " << QString::number(_ent) << "/" << QString::number(_mode) << QT_ENDL;
QSqlQuery query = QSqlQuery();
QString queryString = QString();
if (_mode == -1)
{
return -1;
}
int status = 0;
queryString = QString("SELECT confirmed FROM awarddxcc WHERE dxcc='%1' AND mode='%2' AND lognumber='%4' ").arg(QString::number(_ent)).arg(QString::number(_mode)).arg(QString::number(_logNumber));
if (query.exec(queryString))
{
while (query.next())
{
if ( query.isValid() )
{
if(query.value(0).toString() == "1") // Confirmed
{
query.finish();
return 2;
}
else if(query.value(0).toString() == "0") // Worked
{
if (status < 1)
{
status = 1;
}
}
} // Not present => Not worked
}
query.finish();
}
else
{ // The query fails...
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
//TODO: Manage the query error
return -1;
}
return status; // if arrives to here decision => not worked
}
*/
void Awards::setManageModes(const bool _manageModes)
{
manageModes = _manageModes;
}
bool Awards::updateDXCCBandsStatus(const int _logNumber)
{
//qDebug() << Q_FUNC_INFO << ": " << QString::number(_logNumber);
//QList dxccStatus;
QSqlQuery query;
QString stringQuery = QString();
bool sqlOK = false;
//QString answer;
if (_logNumber>0)
{
//stringQuery = QString("SELECT DISTINCT dxcc, bandid, qsl_rcvd, lotw_qsl_rcvd FROM log WHERE dxcc>0 AND lognumber='%1'ORDER BY dxcc").arg(_logNumber);
stringQuery = QString("SELECT DISTINCT dxcc, bandid, qsl_rcvd, lotw_qsl_rcvd, id FROM log lognumber='%1'ORDER BY dxcc").arg(_logNumber);
}
else
{
stringQuery = QString("SELECT DISTINCT dxcc, bandid, qsl_rcvd, lotw_qsl_rcvd, id FROM log ORDER BY dxcc");
}
int qsos = 0;
sqlOK = query.exec(stringQuery);
if (sqlOK)
{
//qDebug() << Q_FUNC_INFO << " - exec query: " << query.lastQuery ();
dxccStatusList.clear();
while(query.next())
{
if (query.isValid())
{
qsos++;
EntityBandStatus ent;
if (query.value(0).toInt()==0)
{
//qDebug() << Q_FUNC_INFO << " - Returning false for: QSOid" << QString::number(query.value(4).toInt());
return false;
}
ent.dxcc = query.value(0).toInt();
ent.bandid = query.value(1).toInt();
if ((query.value(2).toString () == "Y") || (query.value(3).toString () == "Y"))
{
ent.confirmed = true;
}
else
{
ent.confirmed = false;
}
dxccStatusList.append (ent);
}
else
{
//qDebug() << Q_FUNC_INFO << ": query NOK: " << query.lastQuery ();
query.finish();
return false;
}
}
}
else
{
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
query.finish();
return false;
}
query.finish();
if ((dxccStatusList.length ()<1) && (qsos>0))
{
//qDebug() << Q_FUNC_INFO << " RETURN FALSE" ;
// It may be the case that there are not dxcc
return false;
}
else if (dxccStatusList.length ()<1)
{
//qDebug() << Q_FUNC_INFO << ": dxccStatusList length <1 ";
}
else if(qsos>0)
{
//qDebug() << Q_FUNC_INFO << ": qsos>0 ";
}
else
{
//qDebug() << Q_FUNC_INFO << ": ELSE";
}
//qDebug() << Q_FUNC_INFO << ": dxccStatusList length: " << QString::number(dxccStatusList.length ()) ;
//qDebug() << Q_FUNC_INFO << ": QSOs: " << QString::number(qsos) ;
return true;
}
klog-1.8.6/hamlibclass.h 0000644 0001750 0001750 00000012423 14166020421 014073 0 ustar devel devel #ifndef HAMLIBCLASS_H
#define HAMLIBCLASS_H
/***************************************************************************
hamlibclass.h - description
-------------------
begin : oct 2020
copyright : (C) 2020 by Jaime Robles
user : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
#include
#include
#include
#include
//#include
#include
#include
#include
#include
#include
#include "klogdefinitions.h"
// Potential fix of hamlib 4.2 migration
#ifndef HAMLIB_FILPATHLEN
#define HAMLIB_FILPATHLEN FILEPATHLEN
#endif
#ifndef FILPATHLEN
#define FILPATHLEN 100
#endif
class HamLibClass : public QObject
{
Q_OBJECT
public:
explicit HamLibClass(QObject *parent = nullptr);
~HamLibClass();
QStringList getRigList ();
int getModelIdFromName (const QString &_name);
QString getNameFromModelId(const int _id);
void setModelId(const int _id);
void setPort(const QString &_port);
void setPoll(const int _milsecs);
void setDataBits(const int data);
void setStop(const int _stop);
void setFlow(const QString &_flow);
void setParity(const QString &_parity);
void setSpeed(const int _speed);
void setRTS(const QString &_state);
void setDTR(const QString &_state);
void setFreq(const double _fr);
void setMode(const QString &_m);
void setReadOnly(const bool _r);
bool isModeADIFMode(const QString &_m);
void setNetworkAddress(const QString &_address);
void setNetworkPort(const int _port);
bool init(bool _active);
bool stop();
bool readRadio(bool _forceRead);
bool isRunning();
void initClass();
void clean();
void checkErrorCountAndStop();
double getFrequency();
//void showDebugLog(const QString &_func, const QString &_log);
//bool openSerialPort();
//bool closeSerialPort();
signals:
void freqChanged(double newFreq);
void modeChanged(QString newFreq);
public slots:
void slotTimer();
private:
bool readRadioInternal(bool _forceRead);
static int addRigToList(const struct rig_caps* caps, void* data);
QString hamlibMode2Mode(rmode_t _rmode);
bool errorManage(const QString &_func, const int _errorcode);
//rmode_t mode2HamlibMode(const QString &_m);
QStringList strings;
QTimer *timer;
QMap rigName2RigId;
QMap rigId2RigName;
RIG *my_rig; // handle to rig (instance)
freq_t freq, freq_old; // Radio freq
rmode_t rmode, mode_old; // Radio mode
serial_parity_e sparity;
serial_handshake_e shandshake;
serial_control_state_e srts, sdtr;
int retcode; // generic return code from functions
rig_model_t myrig_model; // Integer radio model
//hamlib_port_t myport; // Hamlib port
pbwidth_t width;
//vfo_t vfo; /* vfo selection */
//int strength; /* S-Meter level */
int bauds; // default 9600
int dataBits; // default 8
int stopBits; // default 1
QString flowControl; // default QSerialPort::NoFLowControl
QString parity; // default QSerialPort::NoParity
QString serialPort;
QString networkAddress;
int networkPort;
int pollInterval; // Poll interval in mSecs
int errorCount; // Number of times that the rig has returned an error since last time OK.
bool rigLaunched;
bool readOnlyMode; // If true, KLog will not modify any parameter (freq/mode...) in the radio. KLog just will follow the radio.
bool justEmitted;
bool reading; // Just a semaphore to prevent several readings
//bool active;
//QSerialPort *m_serial;
};
#endif // HAMLIBCLASS_H
klog-1.8.6/widgets/ 0000755 0001750 0001750 00000000000 14166020421 013104 5 ustar devel devel klog-1.8.6/widgets/showkloglogwidget.cpp 0000644 0001750 0001750 00000005562 14166020407 017367 0 ustar devel devel /***************************************************************************
showkloglogwidget.cpp - description
-------------------
begin : jan 2021
copyright : (C) 2021 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
#include "showkloglogwidget.h"
ShowKLogLogWidget::ShowKLogLogWidget(QWidget *parent) : QWidget(parent)
{
levelComboBox = new QComboBox;
model = new QStringListModel();
//QStringList list;
list.clear();
model->setStringList(list);
logsView = new QListView;
logsView->setModel(model);
createUI();
}
void ShowKLogLogWidget::createUI()
{
QStringList levels;
levels.clear();
//TODO: Link the Level tags to the utilities.h definition
levels << "1-Info" << "2-Debug";
levelComboBox->clear();
levelComboBox->addItems(levels);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(levelComboBox);
layout->addWidget(logsView);
setLayout(layout);
}
void ShowKLogLogWidget::addLog(const QString &_func, QString const &_log, const DebugLogLevel _l)
{
QString msg;
msg = QDateTime::currentDateTime().toString("yyyy/MM/dd-hh:mm:ss") + "-" + _func + ": " + _log;
//qDebug() << Q_FUNC_INFO << ": " << msg;
//QModelIndex index = model->index(0, 0);
//model->setData(index, msg);
if(model->insertRow(0)) {
QModelIndex index = model->index(0, 0);
model->setData(index, msg);
}
}
klog-1.8.6/widgets/onlinemessagewidget.h 0000644 0001750 0001750 00000004444 14166020407 017324 0 ustar devel devel #ifndef ONLINEMESSAGEWIDGET_H
#define ONLINEMESSAGEWIDGET_H
/***************************************************************************
onlinemessagewidget.h - description
-------------------
begin : November 2020
copyright : (C) 2020 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
#include
#include
#include
#include
#include "utilities.h"
class OnlineMessageWidget : public QWidget
{
Q_OBJECT
public:
explicit OnlineMessageWidget(QWidget *parent = nullptr);
int showMessage(QNetworkReply::NetworkError _error, OnLineProvider _prov, OnlineErrorCode _onlineError, OnlineErrorReason _onlineReason, const QString &_msg);
signals:
public slots:
private:
QString translate(QNetworkReply::NetworkError _error);
};
#endif // ONLINEMESSAGEWIDGET_H
klog-1.8.6/widgets/showkloglogwidget.h 0000644 0001750 0001750 00000004652 14166020407 017033 0 ustar devel devel #ifndef SHOWKLOGLOGWIDGET_H
#define SHOWKLOGLOGWIDGET_H
/***************************************************************************
showkloglogwidget.h - description
-------------------
begin : jan 2021
copyright : (C) 2021 by Jaime Robles
email : jaime@robles.es
***************************************************************************/
/*****************************************************************************
* This file is part of KLog. *
* *
* KLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* KLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 . *
* *
*****************************************************************************/
#include
#include
#include