Skip to content

Commit

Permalink
Working on the DXCluster assistant
Browse files Browse the repository at this point in the history
Created the Frequency class
  • Loading branch information
d authored and d committed Apr 23, 2024
1 parent 25d78d8 commit a5bb391
Show file tree
Hide file tree
Showing 12 changed files with 310 additions and 95 deletions.
10 changes: 5 additions & 5 deletions src/awards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,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 @@ -1223,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 @@ -1232,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/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
38 changes: 22 additions & 16 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 @@ -349,8 +350,8 @@ void DXClusterWidget::slotClusterDataArrived()
QStringList qs;
QString dxClusterString;
QString dxCall;
QString dxFrequency;
QString spotBand;
Frequency freq;
bool dxSpot = false;
spotBand = "-1";
//bool isADXSpot = false;
Expand All @@ -360,7 +361,6 @@ void DXClusterWidget::slotClusterDataArrived()
while ( tcpSocket->canReadLine() )
{
spotter.clear();
dxFrequency.clear();
dxCall.clear();
dxEntity = -1;

Expand All @@ -378,8 +378,7 @@ void DXClusterWidget::slotClusterDataArrived()
// It is a "DX de SP0TTER FREC DXCALL"
//0 = DX, 1 = de, 2 = spotter, 3 = Freq, 4 = dxcall, 5 = comment
qDebug() << Q_FUNC_INFO << " - DXCLUSTER->" << dxClusterString << "\nTOKENS: " << tokens;
bool freqOK = false;
double freq = (tokens[0]).toDouble(&freqOK) / 1000; // This freq Check is just for the "else if"



if ((tokens[0] == "DX") && (tokens[1] == "de"))
Expand All @@ -388,27 +387,24 @@ void DXClusterWidget::slotClusterDataArrived()
dxSpot = true;
spotter = tokens[2];
spotter.truncate(spotter.size() - 1);

dxFrequency = QString::number( ((tokens[3]).toDouble(&freqOK))/1000); // Convert KHz to MHz...
bool freqOK = freq.fromQString(tokens[3], KHz) ;
if (!freqOK)
{
qDebug() << Q_FUNC_INFO << " - freqOK false";
return;
}

qDebug() << Q_FUNC_INFO << ": FREQ(if): " << freq.toQString();
dxCall = tokens[4];
dxEntity = world->getQRZARRLId(dxCall);
spotBand = QString::number(dataProxy->getBandIdFromFreq( dxFrequency.toDouble() ) );
spotBand = QString::number(dataProxy->getBandIdFromFreq(freq.toDouble()) );
}
else if ((freqOK) && (util->isValidCall(tokens[1])) )
else if(freq.fromQString(tokens[0], KHz))
{// 18.000 EA0XX
qDebug() << Q_FUNC_INFO << " - Identified: Freq Call";
dxSpot = true;
dxCall = tokens[1];
dxFrequency = tokens[0];
dxFrequency = QString::number(freq); // Freq was calculated before entering the if block
spotter = tokens.last();
spotter.chop(1); // Remove the last char '>'
spotter.remove(0,1); // Remove the first char '<'
spotter = cleanSpotter(tokens.last());
}
else
{
Expand All @@ -423,7 +419,7 @@ void DXClusterWidget::slotClusterDataArrived()
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: " << dxFrequency;
qDebug() << Q_FUNC_INFO << " - Freq: " << freq.toQString();
qDebug() << Q_FUNC_INFO << " - DX: " << dxCall;

dxSpotColor = awards->getQRZDXStatusColor(qs);
Expand Down Expand Up @@ -452,13 +448,23 @@ void DXClusterWidget::slotClusterDataArrived()
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);
emit dxspotArrived(dxCall, freq.toDouble());
}

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()
{
//qDebug() << Q_FUNC_INFO;
Expand Down
2 changes: 2 additions & 0 deletions src/dxcluster/dxcluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ email : [email protected]
#include "../awards.h"
#include "../world.h"
#include "../utilities.h"

#include "../dataproxy_sqlite.h"

class QWidget;
Expand Down Expand Up @@ -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
55 changes: 29 additions & 26 deletions src/dxcluster/dxclusterassistant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,65 +75,68 @@ bool DXClusterAssistant::createUI()

void DXClusterAssistant::newDXClusterSpot(const QString &_call, const double _freq, const QSOStatus _status)
{
qDebug() << Q_FUNC_INFO << " - Start";
//qDebug() << Q_FUNC_INFO << " - Start";
Utilities util(Q_FUNC_INFO);
//if (!util.isValidCall(_call, true))
//{
// qDebug() << Q_FUNC_INFO << " - Not Valid Call: " << _call;
// //qDebug() << Q_FUNC_INFO << " - Not Valid Call: " << _call;
// return;
//}

qDebug() << Q_FUNC_INFO << ": Call: " << _call;
qDebug() << Q_FUNC_INFO << ": Freq: " << QString::number(_freq);
//qDebug() << Q_FUNC_INFO << ": Call: " << _call;
//qDebug() << Q_FUNC_INFO << ": Freq: " << QString::number(_freq);
//qDebug() << Q_FUNC_INFO << ": Status: " << ;
proposedQSOs newArrival;
newArrival.call = _call;
newArrival.freq = _freq;
newArrival.status = _status;
newArrival.priority = 1;
list.append(newArrival);
qDebug() << Q_FUNC_INFO << " - 50";
QString status;
switch (_status) {
//qDebug() << Q_FUNC_INFO << " - 50";

//qDebug() << Q_FUNC_INFO << " - 60";
//qDebug() << Q_FUNC_INFO << QString("Data received: Call: %1 - Freq: %2 - Status: %3").arg(_call).arg(_freq).arg(getStringFromStatus(_status));
addCall();
//qDebug() << Q_FUNC_INFO << " - END";
}

QString DXClusterAssistant::getStringFromStatus(QSOStatus _s)
{
switch (_s) {
case unknown:
status ="unknown";
return "unknown";
break;
case ATNO:
status ="ATNO";
return "ATNO";
break;
case needed:
status ="needed";
return "needed";
break;
case worked:
status ="worked";
return "worked";
break;
case confirmed:
status ="confirmed";
return "confirmed";
break;
default:
status ="unknown";
return "unknown";
break;
}
qDebug() << Q_FUNC_INFO << " - 60";
qDebug() << Q_FUNC_INFO << QString("Data received: Call: %1 - Freq: %2 - Status: %3").arg(_call).arg(_freq).arg(status);
addCall(newArrival);
qDebug() << Q_FUNC_INFO << " - END";
}

void DXClusterAssistant::addCall(proposedQSOs _propQSO)
void DXClusterAssistant::addCall()
{
qDebug() << Q_FUNC_INFO << " - Start";
//qDebug() << Q_FUNC_INFO << " - Start";
tableWidget->clearContents();
tableWidget->setRowCount(0);
qDebug() << Q_FUNC_INFO << ": Lenght of list: " << QString::number(list.count());
//qDebug() << Q_FUNC_INFO << ": Lenght of list: " << QString::number(list.count());
proposedQSOs aux;
foreach(aux, list)
{
qDebug() << Q_FUNC_INFO << "Call: " << aux.call;
QTableWidgetItem *newItemCall = new QTableWidgetItem(aux.call);
QTableWidgetItem *newItemFreq = new QTableWidgetItem(QString::number(aux.freq));
QTableWidgetItem *newItemStatus = new QTableWidgetItem(aux.status);

//qDebug() << Q_FUNC_INFO << "Call: " << aux.call;
QTableWidgetItem *newItemCall = new QTableWidgetItem(aux.call, QTableWidgetItem::Type);
QTableWidgetItem *newItemFreq = new QTableWidgetItem(QString::number(aux.freq), QTableWidgetItem::Type);
QTableWidgetItem *newItemStatus = new QTableWidgetItem(getStringFromStatus(aux.status), QTableWidgetItem::Type);

tableWidget->insertRow(tableWidget->rowCount());
int row = tableWidget->rowCount();
Expand All @@ -142,7 +145,7 @@ void DXClusterAssistant::addCall(proposedQSOs _propQSO)
tableWidget->setItem(row-1, 2, newItemStatus);

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

/*
Expand Down
5 changes: 2 additions & 3 deletions src/dxcluster/dxclusterassistant.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ class DXClusterAssistant : public QWidget

private:
bool createUI();
void addCall(proposedQSOs _propQSO);
void addCall();
QString getStringFromStatus(QSOStatus _s);
QTableWidget *tableWidget;
QHeaderView *hv, *hh;
QList<proposedQSOs> list;
};



#endif // DXCLUSTERASSISTANT_H
Loading

0 comments on commit a5bb391

Please sign in to comment.