Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ea4k/klog
Browse files Browse the repository at this point in the history
  • Loading branch information
d authored and d committed Apr 23, 2024
2 parents 998d2f8 + 1c95647 commit d6b5603
Show file tree
Hide file tree
Showing 16 changed files with 580 additions and 110 deletions.
62 changes: 57 additions & 5 deletions src/awards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,58 @@ QColor Awards::getQRZDXStatusColor(const QStringList &_qs)
return returnedColor;
}

QSOStatus Awards::getQSOStatus(const int &_status)
{
switch (_status) {
case 0:
return ATNO;
break;
case 1:
return needed;
break;
case 2:
return needed;
break;
case 3:
return worked;
break;
case 4:
return needed;
break;
case 5:
return needed;
break;
case 6:
return needed;
break;
case 7:
return needed;
break;
case 8:
return worked;
break;
case 9:
return needed;
break;
case 10:
return worked;
break;
case 11:
return needed;
break;
case 12:
return worked;
break;
case 13:
return confirmed;
break;
//break;
default:
return unknown;
break;
}
}

QString Awards::getDXStatusString (const int &_status)
{
//qDebug() << "Awards::getDXStatusString: " << QString::number(_status);
Expand Down Expand Up @@ -1162,7 +1214,7 @@ void Awards::setColors (const QString &_newOne, const QString &_needed, const QS
if (defaultColor.isValid())
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
defaultColor.setNamedColor(_default.toUpper()); //To be replaced by .fromString in Qt6.6
defaultColor.fromString(QAnyStringView((_default.toUpper()))); //To be replaced by .fromString in Qt6.6
#else
defaultColor.setNamedColor(_default.toUpper()); //To be replaced by .fromString in Qt6.6
#endif
Expand All @@ -1171,7 +1223,7 @@ void Awards::setColors (const QString &_newOne, const QString &_needed, const QS
if (neededColor.isValid())
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
neededColor.setNamedColor(_needed.toUpper()); //To be replaced by .fromString in Qt6.6
neededColor.fromString(QAnyStringView((_needed.toUpper()))); //To be replaced by .fromString in Qt6.6
#else
neededColor.setNamedColor(_needed.toUpper()); //To be replaced by .fromString in Qt6.6
#endif
Expand All @@ -1180,23 +1232,23 @@ void Awards::setColors (const QString &_newOne, const QString &_needed, const QS
if (confirmedColor.isValid())
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
confirmedColor.setNamedColor(_confirmed.toUpper()); //To be replaced by .fromString in Qt6.6
confirmedColor.fromString(QAnyStringView((_confirmed.toUpper()))); //To be replaced by .fromString in Qt6.6
#else
confirmedColor.setNamedColor(_confirmed.toUpper()); //To be replaced by .fromString in Qt6.6
#endif
}
if (newOneColor.isValid())
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
newOneColor.setNamedColor(_newOne.toUpper()); //To be replaced by .fromString in Qt6.6
newOneColor.fromString(QAnyStringView((_newOne.toUpper()))); //To be replaced by .fromString in Qt6.6
#else
newOneColor.setNamedColor(_newOne.toUpper()); //To be replaced by .fromString in Qt6.6
#endif
}
if (workedColor.isValid())
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
workedColor.setNamedColor(_worked.toUpper());
workedColor.fromString(QAnyStringView((_worked.toUpper())));
#else
workedColor.setNamedColor(_worked.toUpper());
#endif
Expand Down
1 change: 1 addition & 0 deletions src/awards.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Awards : public QObject {
int getQSOIdofAward (const int _enti, const int _bandid, const int _log, const bool _confirmed);

int getDXStatus (const QStringList &_qs);
QSOStatus getQSOStatus(const int &_status); // Needs to be called with the output of getDXStatus)
QString getDXStatusString (const int &_status); // Needs to be called with the output of getDXStatus
QString getDXCCStatusBand2(const int _dxcc, const int _band, const int _logNumber=0); // Returns -, W or C (Not worked, worked, Confirmed)
QString getDXCCStatusBand(const int _dxcc, const int _band); // Returns -, W or C (Not worked, worked, Confirmed)
Expand Down
1 change: 1 addition & 0 deletions src/dataproxy_sqlite.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class DataProxy_SQLite : public QObject
int getBandIdFromFreq(const double _n);
QString getBandNameFromFreq(const double _n);


double getLowLimitBandFromBandName(const QString &_sm);
double getLowLimitBandFromBandId(const int _sm);
double getUpperLimitBandFromBandName(const QString &_sm);
Expand Down
124 changes: 65 additions & 59 deletions src/dxcluster/dxcluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ email : [email protected]
*****************************************************************************/
#include <QFont>
#include "dxcluster.h"
#include "../frequency.h"
/*
DXClusterWidget::DXClusterWidget(DataProxy_SQLite *dp, QWidget *parent)
: QWidget(parent)
Expand Down Expand Up @@ -119,7 +120,7 @@ void DXClusterWidget::init()
{
//qDebug() << Q_FUNC_INFO;
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
dxSpotColor.setNamedColor("slategrey"); //To be replaced by .fromString in Qt6.6
dxSpotColor.fromString(QAnyStringView(("slategrey"))); //To be replaced by .fromString in Qt6.6
#else
dxSpotColor.setNamedColor("slategrey"); //To be replaced by .fromString in Qt6.6
#endif
Expand Down Expand Up @@ -218,7 +219,7 @@ void DXClusterWidget::connectToDXCluster()

connect(tcpSocket, SIGNAL(connected()), SLOT(slotClusterSocketConnected()) );
connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(slotClusterDataArrived() ));
connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotClusterDisplayError(QAbstractSocket::SocketError)));
connect(tcpSocket, SIGNAL(errorOcurred(QAbstractSocket::SocketError)), this, SLOT(slotClusterDisplayError(QAbstractSocket::SocketError)));
connect(tcpSocket, SIGNAL(disconnected()), SLOT(slotClusterSocketConnectionClosed()) );
connect(inputCommand, SIGNAL(returnPressed()), this, SLOT(slotClusterSendToServer()) );
connect(clearButton, SIGNAL(clicked()), this, SLOT(slotClusterClearLineInput()) );
Expand Down Expand Up @@ -345,18 +346,24 @@ void DXClusterWidget::setCurrentLog(const int _log)

void DXClusterWidget::slotClusterDataArrived()
{
//qDebug() << Q_FUNC_INFO;
qDebug() << Q_FUNC_INFO;
QStringList qs;
QString dxClusterString;
QString dxCall;
QString dxFrequency;
QString spotBand;
Frequency freq;
bool dxSpot = false;
spotBand = "-1";
//bool isADXSpot = false;
int dxEntity = -1;
QString spotter;

while ( tcpSocket->canReadLine() )
{
spotter.clear();
dxCall.clear();
dxEntity = -1;

dxClusterString = tcpSocket->readLine();
dxClusterString = dxClusterString.trimmed();
// Remove BELL-string if exists
Expand All @@ -365,62 +372,56 @@ void DXClusterWidget::slotClusterDataArrived()

QStringList tokens = dxClusterString.split(" ", QT_SKIP);
if (tokens.size()<2){
qDebug() << Q_FUNC_INFO << " - Tokens < 2";
return;
}
// It is a "DX de SP0TTER FREC DXCALL"
//0 = DX, 1 = de, 2 = spotter, 3 = Freq, 4 = dxcall, 5 = comment
//qDebug() << "DXClusterWidget::slotClusterDataArrived: " << "DXCLUSTER->" << dxClusterString << "\nTOKENS: " << tokens;
qDebug() << Q_FUNC_INFO << " - DXCLUSTER->" << dxClusterString << "\nTOKENS: " << tokens;



if ((tokens[0] == "DX") && (tokens[1] == "de"))
{
//qDebug() << "******************** DXClusterWidget::slotClusterDataArrived: DX DE";
//isADXSpot = true;
QString spotter = tokens[2];
{ // Dx de EA0AA EA0XX
qDebug() << Q_FUNC_INFO << " - Identified: DX de";
dxSpot = true;
spotter = tokens[2];
spotter.truncate(spotter.size() - 1);
dxFrequency = tokens[3];
// Convert KHz to MHz...
//dxFrequency = QString::number(abs (dxFrequency.toFloat())/1000);
dxFrequency = QString::number( (dxFrequency.toDouble())/1000);
dxCall = tokens[4];
dxEntity = world->getQRZARRLId(dxCall);
//
spotBand = QString::number(dataProxy->getBandIdFromFreq( dxFrequency.toDouble() ) );

qs.clear();
//spotBand = QString::number(world->getBandIdFromFreq( dxFrequency ) );
qs << QString::number(dxEntity) << spotBand << "-1" << QString::number(currentLog) ;
//qDebug() << "DXClusterWidget::slotClusterDataArrived: Calling-2: " << QString::number(dxEntity);
dxSpotColor = awards->getQRZDXStatusColor(qs);
if (showDxMarathon)
bool freqOK = freq.fromQString(tokens[3], KHz) ;
if (!freqOK)
{
if (awards->isDXMarathonNeed(dxEntity, world->getQRZCqz(dxCall), QDateTime::currentDateTime().date().year(), currentLog))
{
dxClusterString = dxClusterString + " ### Needed for DXMarathon - " + QString::number(QDateTime::currentDateTime().date().year()) + " ###";
}
qDebug() << Q_FUNC_INFO << " - freqOK false";
return;
}
//qDebug() << "DX de ->" << "Spotter: " << spotter << "Freq: "<< dxFrequency << "DX: " << dxCall;

qDebug() << Q_FUNC_INFO << ": FREQ(if): " << freq.toQString();
dxCall = tokens[4];
dxEntity = world->getQRZARRLId(dxCall);
spotBand = QString::number(dataProxy->getBandIdFromFreq(freq.toDouble()) );
}
else if(freq.fromQString(tokens[0], KHz))
{// 18.000 EA0XX
qDebug() << Q_FUNC_INFO << " - Identified: Freq Call";
dxSpot = true;
dxCall = tokens[1];
spotter = cleanSpotter(tokens.last());
}
else if ((tokens[0] == "To") && (tokens[1] == "ALL"))
else
{
//qDebug() << "DXClusterWidget::slotClusterDataArrived: TO ALL";
qDebug() << Q_FUNC_INFO << " - Identified: Not a DXSpot";
dxSpot = false;
dxSpotColor = awards->getDefaultColor();
}
//else if ( (dxClusterString.length()>=5) && (world->checkQRZValidFormat(tokens[1])) && (tokens[0]!="login:"))
else if ( (dxClusterString.length()>=5) && (util->isValidCall(tokens[1])) && (tokens[0]!="login:"))
{ // Freq / DXCall / Date // time
//_qs << QRZ << Freq in MHz << lognumber;
//qDebug() << "DXClusterWidget::slotClusterDataArrived: LENGTH >= 5";
//qDebug() << "DXClusterWidget::slotClusterDataArrived: token0=" << tokens[0] << " / token1=" << tokens[1];
//isADXSpot = true;
dxCall = tokens[1];
dxFrequency = tokens[0];
dxFrequency = QString::number( (dxFrequency.toDouble())/1000);

if (dxSpot)
{
qs.clear();
spotBand = QString::number(dataProxy->getBandIdFromFreq( dxFrequency.toDouble() ) );
dxEntity = world->getQRZARRLId(dxCall);
//qDebug() << "DXClusterWidget::slotClusterDataArrived: Calling-1: " << QString::number(dxEntity);
qs << QString::number(dxEntity) << spotBand << "-1" << QString::number(currentLog) ;
qDebug() << Q_FUNC_INFO << " - DX_Entity: " << QString::number(dxEntity);
qDebug() << Q_FUNC_INFO << " - DX Spotter: " << spotter ;
qDebug() << Q_FUNC_INFO << " - Freq: " << freq.toQString();
qDebug() << Q_FUNC_INFO << " - DX: " << dxCall;

dxSpotColor = awards->getQRZDXStatusColor(qs);
if (showDxMarathon)
{
Expand All @@ -430,33 +431,38 @@ void DXClusterWidget::slotClusterDataArrived()
}
}
}
else
{
//qDebug() << "DXClusterWidget::slotClusterDataArrived: DEFAULT";
dxSpotColor = awards->getDefaultColor();
}

//TODO: Change the "-1" by the mode
if (!checkIfNeedsToBePrinted(QString::number(dxEntity), spotBand.toInt(), -1))
{
//qDebug() << "DXClusterWidget::slotClusterDataArrived - Not to be printed!: " << dxCall;
qDebug() << Q_FUNC_INFO << " - Not to be printed!: " << dxCall;
return;
}

QListWidgetItem *item = new QListWidgetItem();
item->setForeground(QBrush(dxSpotColor));
item->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
item->setText(dxClusterString);

dxClusterListWidget->insertItem(0,item);
if (util->isValidCall (dxCall))
{
//void dxspotArrived(const QString &_call, const QString &_text, const double _freq);
QString locator = world->getLocator (dxEntity);
emit dxspotArrived(dxCall, locator, dxFrequency.toDouble());
}

if (!dxSpot)
return;

qDebug() << Q_FUNC_INFO << " - Freq-string: " << freq.toQString();
qDebug() << Q_FUNC_INFO << " - Freq-double: " << QString::number(freq.toDouble());
qDebug() << Q_FUNC_INFO << " - Everything OK emitting...";
emit dxspotArrived(dxCall, freq.toDouble());
}
//qDebug() << "--------------------- DXClusterWidget::slotClusterDataArrived: " << dxClusterString;
//qDebug() << "DXClusterWidget::slotClusterDataArrived: " << dxClusterString;

qDebug() << Q_FUNC_INFO << " - END";
}

QString DXClusterWidget::cleanSpotter(const QString _call)
{
QString spotter = _call;
spotter.chop(1); // Remove the last char '>'
spotter.remove(0,1);
return spotter;
}

void DXClusterWidget::slotClusterSocketConnected()
Expand Down
14 changes: 8 additions & 6 deletions src/dxcluster/dxcluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ email : [email protected]
* *
*****************************************************************************/

#include <QWidget>
#include <QSettings>
//#include <QtWidgets>
#include <QtWidgets>
#include <QTcpSocket>
#include <QObject>
#include "awards.h"
#include "world.h"
#include "utilities.h"
#include "dataproxy_sqlite.h"
#include "../awards.h"
#include "../world.h"
#include "../utilities.h"

#include "../dataproxy_sqlite.h"

class QWidget;
class QTcpSocket;
Expand Down Expand Up @@ -79,7 +80,7 @@ private slots:

signals:
void dxspotclicked(const QStringList &_qs); // DXSpotCall, DX-Freq, doubleClicked
void dxspotArrived(const QString &_call, const QString &_text, const double _freq);
void dxspotArrived(const QString &_call, const double _freq);
//void dxspot(const QString &_spot); // The text string to be saved

private:
Expand All @@ -91,6 +92,7 @@ private slots:
bool checkIfNeedsToBePrinted(const QString &_DXEntity, const int _band, const int _mode);
void saveSpot (const QString &_spot);
bool openFile();
QString cleanSpotter(const QString _call);
void addData(); //TO BE DELETED, JUST FOR TESTING PURPOSES


Expand Down
Loading

0 comments on commit d6b5603

Please sign in to comment.