Skip to content

Commit

Permalink
Frequency work
Browse files Browse the repository at this point in the history
  • Loading branch information
d authored and d committed Apr 30, 2024
1 parent 3a74502 commit 8516b74
Show file tree
Hide file tree
Showing 14 changed files with 362 additions and 201 deletions.
2 changes: 0 additions & 2 deletions src/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6649,9 +6649,7 @@ bool DataBase::updateAwardWAZTable()
{
//qDebug() << "DataBase::updateAwardWAZTable" ;
QList<AwarddxccEntry> dxccStatusList;
//QList<AwarddxccEntryCheck> dxccStatusListCheck;
dxccStatusList.clear();
//dxccStatusListCheck.clear();

AwarddxccEntry awardEntry;
awardEntry.dxcc = QString();
Expand Down
9 changes: 0 additions & 9 deletions src/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,6 @@ struct AwarddxccEntry
QString qsoID;
};

struct AwarddxccEntryCheck
{ // Information to update the awarddxcc table; For other Award tables, the DXCC is just the ID of the award element
QString dxcc;
QString band;
QString mode;
QString status;
QString logNumber;
};

class DataBase : public QObject
{
Q_OBJECT
Expand Down
114 changes: 28 additions & 86 deletions src/dxcluster/dxcluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,13 @@ void DXClusterWidget::slotClusterDXClusterWidgetItemDoubleClicked( QListWidgetIt
{
//qDebug() << Q_FUNC_INFO << item->text();

DXSpot spot;
QStringList ql;
ql.clear();

if (!item)
return;

spot = readItem(((item->data(0)).toString()).simplified());
DXSpot spot = readItem(((item->data(0)).toString()).simplified());
if (!spot.valid)
return;

Expand Down Expand Up @@ -339,7 +338,7 @@ void DXClusterWidget::slotClusterDataArrived()
QString dxCall;
QString spotBand;
Frequency freq;
DXSpot spot;


spotBand = "-1";

Expand All @@ -355,14 +354,17 @@ void DXClusterWidget::slotClusterDataArrived()
dxClusterString = dxClusterString.trimmed();
// Remove BELL-string if exists
dxClusterString = dxClusterString.remove("\a");
qDebug() << Q_FUNC_INFO << ": Line: " << dxClusterString;

saveSpot(dxClusterString);
spot = readItem(dxClusterString);
DXSpot spot = readItem(dxClusterString);

if (spot.valid)
{
qDebug() << Q_FUNC_INFO << " - Spot IS valid";
_entityStatus.entityId = world->getQRZARRLId(dxCall);

spotBand = QString::number(dataProxy->getBandIdFromFreq(freq.toDouble()) );

dxSpotColor = awards->getQRZDXStatusColor(_entityStatus);
if (showDxMarathon)
{
Expand All @@ -374,6 +376,7 @@ void DXClusterWidget::slotClusterDataArrived()
}
else
{
qDebug() << Q_FUNC_INFO << " - Spot IS NOT valid";
dxSpotColor = awards->getDefaultColor();
}

Expand All @@ -396,10 +399,12 @@ void DXClusterWidget::slotClusterDataArrived()
if (!spot.valid)
return;

qDebug() << Q_FUNC_INFO << " - DXCall: " << spot.dxcall;
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(spot.dxcall, freq);

emit dxspotArrived(spot.dxcall, freq.toDouble());
}

qDebug() << Q_FUNC_INFO << " - END";
Expand Down Expand Up @@ -553,16 +558,10 @@ void DXClusterWidget::slotClusterDXClusterWidgetItemSelected()
{
//qDebug() << Q_FUNC_INFO;
QListWidgetItem * item = dxClusterListWidget->currentItem();
DXSpot spot;
QStringList ql;
ql.clear();

spot = readItem(((item->data(0)).toString()).simplified());
if (ql.length()==2)
{
ql << "selected";
DXSpot spot = readItem(((item->data(0)).toString()).simplified());
if (spot.valid)
emit dxspotclicked(spot);
}
}

void DXClusterWidget::slotClusterDXClusterWidgetItemEntered( QListWidgetItem * item )
Expand All @@ -571,13 +570,13 @@ void DXClusterWidget::slotClusterDXClusterWidgetItemEntered( QListWidgetItem * i
/*
This code comes from slotClusterDXClusterWidgetItemDoubleClicked
*/
DXSpot spot;

QString tip;
tip.clear();

if (item)
{
spot = readItem(((item->data(0)).toString()).simplified());
DXSpot spot = readItem(((item->data(0)).toString()).simplified());
if (spot.valid)
{
tip = world->getQRZEntityName(spot.dxcall);
Expand All @@ -595,9 +594,11 @@ bool DXClusterWidget::isConnected()

DXSpot DXClusterWidget::readItem(const QString _stringSpot)
{
//qDebug() << Q_FUNC_INFO;
// Returns: dxSpot
DXSpot spot;
qDebug() << Q_FUNC_INFO;

DXSpot spot = DXSpot();
spot.valid = false;

if (_stringSpot.length()<5)
return spot;
Frequency _fr;
Expand All @@ -612,6 +613,12 @@ DXSpot DXClusterWidget::readItem(const QString _stringSpot)
if ( (fields.at(0) == "DX" ) && (fields.at(1) == "de" ) )
{ // DX de EA0XXX: 21200.1 EA0K The comment 1550
qDebug() << Q_FUNC_INFO << ": Identified: DX de";
qDebug() << Q_FUNC_INFO << ": 0: " << fields.at(0);
qDebug() << Q_FUNC_INFO << ": 1: " << fields.at(1);
qDebug() << Q_FUNC_INFO << ": 2: " << fields.at(2);
qDebug() << Q_FUNC_INFO << ": 3: " << fields.at(3);
qDebug() << Q_FUNC_INFO << ": 4: " << fields.at(4);
qDebug() << Q_FUNC_INFO << ": 5: " << fields.at(5);
spot.spotter = fields.at(2);
spot.freq.fromQString((fields.at(3)), KHz);
spot.dxcall = fields.at(4);
Expand All @@ -637,70 +644,6 @@ DXSpot DXClusterWidget::readItem(const QString _stringSpot)
}

return spot;

/*
/////// NEW CODE
//int currentEntity;
QString dxCallsign, dxFreq;
if (!item)
return spot;
fields.clear();
dxClusterString = ((item->data(0)).toString()).simplified();
fields << dxClusterString.split(" ");
if ( (fields.at(0) == "DX" ) && (fields.at(1) == "de" ) )
{ // DX de EA0XXX: 21200.1 EA0K The comment 1550
if ( world->getQRZARRLId(fields.at(4))> 0 )
{
spot.dxcall = (fields.at(4)).toUpper();
spot.freq().fromQString(fields.at(3), KHz);
if (spot.freq().isValid())
{ // The frecuency is valid
return spot;
}
else
{ // the frecuency is not a number!
dxCallsign.clear();
dxFreq.clear();
fields.clear();
}
}
else
{ // The callsign is not from a valid country
// TODO: if it is from a new entity/prefix it would not work.
//qDebug() << Q_FUNC_INFO << " Entity not valid" ;
spot.dxcall = QString();
spot.spotter = QString();
spot.comment = QString();
spot.freq().clear();
}
}
//else if (( isAFrecuency(fields.at(0) ) ) && ( isACall(fields.at(1)) ) )
else if ( (((fields.at(0)).toDouble()) > 0.0 )&& ( world->getQRZARRLId(fields.at(1))> 0 ) )
{ // 14205.0 EA0K 5-Mar-2012 1500Z <EA0XXX>
dxCallsign = (fields.at(1)).toUpper();
dxFreq = fields.at(0);
fields.clear();
fields << dxCallsign << dxFreq;
spot.dxcall = dxCallsign;
spot.freq().fromQString(dxFreq, KHz);
return spot;
}
else
{
spot.dxcall = QString();
spot.spotter = QString();
spot.comment = QString();
spot.freq().clear();
spot.clickStatus = NoClick;
spot.dateTime = QDateTime();
}
return spot;
*/
}

void DXClusterWidget::setDXClusterServer(const QString &clusterToConnect, const int portToConnect)
Expand Down Expand Up @@ -758,16 +701,15 @@ void DXClusterWidget::slotRightButton(const QPoint& pos)
//int row = (dxClusterListWidget->indexAt(pos)).row();
//qDebug() << Q_FUNC_INFO << " row: " << QString::number(row);
QListWidgetItem * item = dxClusterListWidget->currentItem();
DXSpot spot;

spot = readItem(((item->data(0)).toString()).simplified());
DXSpot spot = readItem(((item->data(0)).toString()).simplified());
if ((spot.valid) && (spot.clickStatus == RightClick) )
{
rightButtonFromLogMenu(spot);
}
}

void DXClusterWidget::rightButtonFromLogMenu(DXSpot _spot)
void DXClusterWidget::rightButtonFromLogMenu(const DXSpot &_spot)
{
// This function creates the context menu
//qDebug() << Q_FUNC_INFO;
Expand Down
33 changes: 22 additions & 11 deletions src/dxcluster/dxcluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,26 @@ email : [email protected]
class QWidget;
class QTcpSocket;

class Frequency;

struct DXSpot { // Used to pass a list of data from Awards to dxccstatuswidget
QString dxcall = QString();
Frequency freq = Frequency();
QString spotter = QString();
QString comment = QString();
QDateTime dateTime = QDateTime();
MouseClicks clickStatus = SingleClick;
bool valid = false;
QString dxcall;
Frequency freq;
QString spotter;
QString comment;
QDateTime dateTime;
MouseClicks clickStatus;
bool valid;
DXSpot() {valid = false;}
DXSpot(const DXSpot& other) {
dxcall = other.dxcall;
freq = other.freq; // Might need a copy constructor for Frequency as well
spotter = other.spotter;
comment = other.comment;
dateTime = other.dateTime;
clickStatus = other.clickStatus;
valid = other.valid;
}
};

class DXClusterWidget : public QWidget
Expand All @@ -72,7 +83,7 @@ class DXClusterWidget : public QWidget
void loadSettings();
void setDXClusterServer(const QString &clusterToConnect, const int portToConnect);

void rightButtonFromLogMenu(DXSpot _spot);
void rightButtonFromLogMenu(const DXSpot &_spot);
//void sendSpotToCluster(const QString &_dx, const QString &_freq);

private slots:
Expand All @@ -91,8 +102,8 @@ private slots:
void slotCheckQRZCom();

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

private:
Expand All @@ -101,7 +112,7 @@ private slots:
void createActions();
void connectToDXCluster();
//QStringList readItem(QListWidgetItem * _stringSpot);
DXSpot readItem (const QString _stringSpot);
DXSpot readItem(const QString _stringSpot);
bool checkIfNeedsToBePrinted(EntityStatus _entityStatus);
void saveSpot (const QString &_spot);
bool openFile();
Expand Down
9 changes: 0 additions & 9 deletions src/dxcluster/dxclusterassistant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,6 @@ void DXClusterAssistant::addCall()
tableWidget->setItem(row-1, 0, newItemCall);
//tableWidget->setItem(row-1, 1, newItemFreq);
tableWidget->setItem(row-1, 2, newItemStatus);

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

/*
QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(
(row+1)*(column+1)));
tableWidget->setItem(row, column, newItem);
*/
13 changes: 8 additions & 5 deletions src/dxcluster/dxclusterassistant.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ email : [email protected]
#include "../utilities.h"
#include "../frequency.h"

struct proposedQSOs { // Used to pass a list of data from Awards to dxccstatuswidget
QString call = QString();
Frequency freq;
int priority = -1;
QSOStatus status = unknown;
class Frequency;

struct proposedQSOs
{ // Used to pass a list of data from Awards to dxccstatuswidget
QString call;
//Frequency freq;
int priority;
QSOStatus status;
};

class DXClusterAssistant : public QWidget
Expand Down
Loading

0 comments on commit 8516b74

Please sign in to comment.