Skip to content

Commit

Permalink
Some functions deprecation and bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ea4k committed Dec 29, 2024
1 parent 79dd936 commit b6921ab
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 22 deletions.
1 change: 1 addition & 0 deletions devscripts/generate-coverage.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
lcov -c -d ../src --output-file ./coverage.info
genhtml coverage.info --output-directory out
16 changes: 11 additions & 5 deletions src/callsign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ Callsign::Callsign(const QString &callsign, QObject *parent) : QObject{parent},
//qDebug() << Q_FUNC_INFO << " - 50";

prefValid = true;
homePrefix = matchPrefix.captured("prefix");
homeFullPrefix = matchPrefix.captured("prefix");
homeSpecialPrefix = matchPrefix.captured("specialprefix");
hostSpecialNumber1 = match.captured("specialareanumber").toInt(&hostSpecialNumberExist1);
homeNormalPrefix = match.captured("normalprefix");
Expand All @@ -242,13 +242,19 @@ Callsign::Callsign(const QString &callsign, QObject *parent) : QObject{parent},
// Now we have the data, let's select the good one

if (hostSpecialNumberExist1)
{
homePrefix = homeSpecialPrefix;
homeAreaNumber = hostSpecialNumber1;
}
else if (!homeAreaNumberExist)
homeAreaNumber = -1;
{
homeAreaNumber = 0;
}


//qDebug() << Q_FUNC_INFO << " - @ homeFullPrefix : " << homeFullPrefix;
//qDebug() << Q_FUNC_INFO << " - @ homePrefix : " << homePrefix;
//qDebug() << Q_FUNC_INFO << " - @ homeAreaNumber : " << QString::number(homeAreaNumber);
qDebug() << Q_FUNC_INFO << " - @ homeFullPrefix : " << homeFullPrefix;
qDebug() << Q_FUNC_INFO << " - @ homePrefix : " << homePrefix;
qDebug() << Q_FUNC_INFO << " - @ homeAreaNumber : " << QString::number(homeAreaNumber);
}
else
{
Expand Down
1 change: 1 addition & 0 deletions src/dxcluster/dxspot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
DXSpot::DXSpot()
{
valid = false;
clickStatus = NoClick;
}
/*
DXSpot::DXSpot(DXSpot *_other)
Expand Down
1 change: 1 addition & 0 deletions src/frequency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Frequency::Frequency(){}
Frequency::Frequency(const double _f, FreqUnits _u)
{
freq = normalize(_f, _u);
setTolerance(1, _u);
}

Frequency::~Frequency(){}
Expand Down
34 changes: 21 additions & 13 deletions src/inputwidgets/mainwindowinputothers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,40 +786,48 @@ void MainWindowInputOthers::setEntityAndPrefix(const int _entity, const QString
setEntity(_entity);

Callsign callsign(_qrz);
QString prefixFromEntityNumber = dataProxy->getEntityMainPrefix(_entity); // The main prefix of the entity.

QString mainPref = dataProxy->getEntityMainPrefix(_entity); // The main prefix of the entity.
QString mainToUse = callsign.getHostFullPrefix(); // The default is that showAll is not checked. Main prefix+ the area
QString prefUsed = callsign.getHostPrefix(); // The default is that showAll is not checked
Callsign entityCall(prefixFromEntityNumber); // To check if the prefixFromEntity is the main or not (EA->main, AM-> nor main, it should be EA)
QString prefixForSubdivision = prefixFromEntityNumber;

// TODO: This function must be improved and find what shoudl be used to identify the right data



QString hostFullPrefix = callsign.getHostFullPrefix(); // The default is that showAll is not checked. Main prefix+ the area
QString hostPrefix = callsign.getHostPrefix(); // The default is that showAll is not checked

qDebug() << Q_FUNC_INFO << " - 20";
if (showAllCheckBox->isChecked())
{ // The prefix without the number should be used.
// be careful with prefixes like EA8/EA/EA6 or E73 / E7
qDebug() << Q_FUNC_INFO << " - 21";
mainToUse = mainPref;
prefUsed = callsign.getHostPrefix();
hostFullPrefix = prefixFromEntityNumber;
hostPrefix = callsign.getHostPrefix();
}
qDebug() << Q_FUNC_INFO << " - 30";

qDebug() << Q_FUNC_INFO << "mainToUse: " << mainToUse;
qDebug() << Q_FUNC_INFO << "mainPref: " << mainPref;
qDebug() << Q_FUNC_INFO << "prefUsed: " << prefUsed;
qDebug() << Q_FUNC_INFO << "hostFullPrefix: " << hostFullPrefix;
qDebug() << Q_FUNC_INFO << "prefixFromEntityNumber: " << prefixFromEntityNumber;
qDebug() << Q_FUNC_INFO << "hostPrefix: " << hostPrefix;

if ((mainToUse.isEmpty()) && (prefUsed.isEmpty()))
if ((hostFullPrefix.isEmpty()) && (hostPrefix.isEmpty()))
return;

qDebug() << Q_FUNC_INFO << " - 40";
QList<PrimarySubdivision> subdivisions;
subdivisions.clear();
subdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, prefUsed));
subdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, hostPrefix));
if (subdivisions.length()<1)
{
qDebug() << Q_FUNC_INFO << " - 50";
qDebug() << Q_FUNC_INFO << " - Subdivisions is empty with prefUSed, running for the main prefix";
subdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, mainToUse));
qDebug() << Q_FUNC_INFO << " - Subdivisions is empty with hostPrefix, running for the main prefix";
subdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, hostFullPrefix));
if (subdivisions.length()<1)
{
qDebug() << Q_FUNC_INFO << " - 55";
qDebug() << Q_FUNC_INFO << " - Subdivisions is empty with mainpref, running just with the entity";
qDebug() << Q_FUNC_INFO << " - Subdivisions is empty with mainprefix, running just with the entity";
subdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, QString()));
}
qDebug() << Q_FUNC_INFO << " - 59";
Expand Down
3 changes: 2 additions & 1 deletion src/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,8 @@ QString Utilities::getCheckedComplexCall(const QString &_c)
}

QString Utilities::getMainCallFromComplexCall(const QString &_complexCall)
{ // Return the part of the call that provides entity and prefix information:
{ //TODO: To be replaced by QString Callsign::getHostFullPrefix(bool getHomeIfEmpty=true);
// Return the part of the call that provides entity and prefix information:
// EA4K/F => F
// VK9/EA4K => VK9
// EA4K/MM => EA4K
Expand Down
5 changes: 3 additions & 2 deletions src/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <QtWidgets>
#include <QPalette>
#include <QtDebug>
#include "global.h" // Remove when all deprecated functions are removed
#include "locator.h"
#include "klogdefinitions.h"
#include "adif.h"
Expand Down Expand Up @@ -101,7 +102,7 @@ class Utilities : public QObject {
// Validations
bool isValidDate(const QDate _d);
bool isValidDateTime(const QString &_d);
bool isValidCall(const QString &_c, bool _force=false);
KLOG_DEPRECATED bool isValidCall(const QString &_c, bool _force=false); // To be replaced by Callsign::isValid

bool isSameFreq(const double fr1, const double fr2);
bool isValidBandId(const int _b);
Expand Down Expand Up @@ -133,7 +134,7 @@ class Utilities : public QObject {
bool areThoseListsTheSame(const QStringList &_list1, const QStringList &_list2);
//QString getADIFField(const QString &_fieldName, const QString &_data);

QString getMainCallFromComplexCall(const QString &_complexCall); // F from F/EA4K/p, EA4K from EA4K/p or EA4K from EA4K
KLOG_DEPRECATED QString getMainCallFromComplexCall(const QString &_complexCall); //TODO: To be replaced by QString Callsign::getHostFullPrefix(bool getHomeIfEmpty=true);
QString getAValidCall (const QString &_wrongCall);
QString getPrefixFromCall(const QString &_c, bool withAreaNumber = false);
int getAreaNumberFromCall(const QString &_c);
Expand Down
2 changes: 1 addition & 1 deletion tests/tst_callsign/tst_callsign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void tst_Callsign::test_callsigns_data()
QTest::newRow("CO7WT/6Y") << "CO7WT/6Y" << "CO7WT/6Y" << "6Y" << "6Y" << -1 << "CO7WT" << "CO7" << "CO" << 7 << "WT" << "" << true << true;
QTest::newRow("AM100") << "AM100" << "" << "" << "" << -1 << "" << "AM100" << "AM" << 100 << "" << "" << true << false;
QTest::newRow("K1") << "K1" << "" << "" << "" << -1 << "" << "K1" << "K" << 1 << "" << "" << true << false;
QTest::newRow("KB1") << "KB1" << "" << "" << "" << -1 << "" << "KB1" << "KB" << 1 << "" << "" << true << false;
QTest::newRow("KB1") << "KB1" << "" << "" << "" << -1 << "" << "KB1" << "KB" << 1 << "" << "" << true << false;
QTest::newRow("EA") << "EA" << "" << "" << "" << -1 << "" << "EA" << "EA" << -1 << "" << "" << true << false;
QTest::newRow("2E3") << "2E3" << "" << "" << "" << -1 << "" << "2E3" << "2E" << 3 << "" << "" << true << false;
QTest::newRow("E74") << "E74" << "" << "" << "" << -1 << "" << "E74" << "E7" << 4 << "" << "" << true << false;
Expand Down

0 comments on commit b6921ab

Please sign in to comment.