Skip to content

Commit

Permalink
Subdivisions for EA4 are back
Browse files Browse the repository at this point in the history
  • Loading branch information
ea4k committed Jan 1, 2025
1 parent 3fdd953 commit 368e72c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
43 changes: 29 additions & 14 deletions src/callsign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,31 +244,36 @@ void Callsign::initialize(const QString &callsign)
}
else if ( matchPrefix.hasMatch() )
{
//qDebug() << Q_FUNC_INFO << " - 50";
qDebug() << Q_FUNC_INFO << " - 50";

prefValid = true;
homeFullPrefix = matchPrefix.captured("prefix");
homeSpecialPrefix = matchPrefix.captured("specialprefix");
hostSpecialNumber1 = match.captured("specialareanumber").toInt(&hostSpecialNumberExist1);
homeNormalPrefix = match.captured("normalprefix");
homeAreaNumber = match.captured("areanumber").toInt(&homeAreaNumberExist);

hostFullPrefix = matchPrefix.captured("hostprefix");
hostPrefix = matchPrefix.captured("hostnormalprefix");
hostSpecialPrefix1 = matchPrefix.captured("hostspecialprefix");
hostSpecialNumber1 = matchPrefix.captured("hostspecialareanumber").toInt(&hostSpecialNumberExist1);
hostAreaNumber = matchPrefix.captured("hostareanumber").toInt(&homeAreaNumberExist);

qDebug() << Q_FUNC_INFO << " - hostFullPrefix: " << hostFullPrefix;
qDebug() << Q_FUNC_INFO << " - hostSpecialPrefix: " << hostSpecialPrefix1;
qDebug() << Q_FUNC_INFO << " - homeNormalPrefix: " << homeNormalPrefix;

// Now we have the data, let's select the good one

if (hostSpecialNumberExist1)
{
homePrefix = homeSpecialPrefix;
homeAreaNumber = hostSpecialNumber1;
hostPrefix = hostSpecialPrefix1;
hostAreaNumber = hostSpecialNumber1;
}
else if (!homeAreaNumberExist)
{
homeAreaNumber = 0;
hostAreaNumber = 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 << " - @ hostFullPrefix : " << hostFullPrefix;
qDebug() << Q_FUNC_INFO << " - @ hostPrefix : " << hostPrefix;
qDebug() << Q_FUNC_INFO << " - @ hostAreaNumber : " << QString::number(hostAreaNumber);
}
else
{
Expand Down Expand Up @@ -303,7 +308,7 @@ QString Callsign::prefixRegExString()
//qDebug() << Q_FUNC_INFO;
// Returns a REGEX string that matches a hamradio prefix like F in F/EA4K/QRP or EA6 in EA6/EA4K
QString aux = getSpecialPrefixes();
return QString("^(?<prefix>(?<specialprefix>%1)(?<specialareanumber>[0-9]*)|(?<normalprefix>B|F|G|I|K|M|N|R|U|W|[A-Z][0-9]|[A-Z]{1,2}|[0-9][A-Z])(?<areanumber>[0-9]*))$").arg(aux);
return QString("^(?<hostprefix>(?<hostspecialprefix>%1)(?<hostspecialareanumber>[0-9]*)|(?<hostnormalprefix>B|F|G|I|K|M|N|R|U|W|[A-Z][0-9]|[A-Z]{1,2}|[0-9][A-Z])(?<hostareanumber>[0-9]*))").arg(aux);
}

QString Callsign::getSpecialPrefixes()
Expand All @@ -313,7 +318,17 @@ QString Callsign::getSpecialPrefixes()
// if getHomeIfEmpty is true and no hostprefix is identified, it will return homePrefix
QString Callsign::getCallsign() {return fullCall;}
QString Callsign::getHostFullPrefix(bool getHomeIfEmpty) {if (getHomeIfEmpty && (hostFullPrefix.length()<=0)) return homeFullPrefix; else return hostFullPrefix;}
QString Callsign::getHostPrefix(bool getHomeIfEmpty) {if (getHomeIfEmpty && (hostPrefix.length()<=0)) return homePrefix; else return hostPrefix;}
QString Callsign::getHostPrefix(bool getHomeIfEmpty)
{
qDebug() << Q_FUNC_INFO << " - hostPrefix: " << hostPrefix;
qDebug() << Q_FUNC_INFO << " - homePrefix: " << homePrefix;
if (getHomeIfEmpty && (hostPrefix.length()<=0))
{return homePrefix;}
else
{return hostPrefix;}


}
int Callsign::getHostAreaNumber(bool getHomeIfEmpty) {if (getHomeIfEmpty && (hostAreaNumber<0)) return homeAreaNumber; else return hostAreaNumber;}

QString Callsign::getHomeCallsign() {return homeCallsign;}
Expand Down
10 changes: 7 additions & 3 deletions src/inputwidgets/mainwindowinputothers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,10 +802,14 @@ void MainWindowInputOthers::setEntityAndPrefix(const int _entity, const QString

// 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

QString hostFullPrefix = callsign.getHostFullPrefix(true); // The default is that showAll is not checked. Main prefix+ the area
QString hostPrefix = callsign.getHostPrefix(true); // The default is that showAll is not checked
qDebug() << Q_FUNC_INFO << " - 20";
qDebug() << Q_FUNC_INFO << "hostFullPrefix: " << hostFullPrefix;
qDebug() << Q_FUNC_INFO << "hostPrefix: " << hostPrefix;



if (showAllCheckBox->isChecked())
{ // The prefix without the number should be used.
// be careful with prefixes like EA8/EA/EA6 or E73 / E7
Expand Down
1 change: 1 addition & 0 deletions tests/tst_callsign/tst_callsign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ void tst_Callsign::test_callsigns_data()
QTest::newRow("K1") << "K1" << "" << "" << "" << -1 << "" << "K1" << "K" << 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("EA4") << "EA4" << "" << "" << "" << -1 << "" << "EA4" << "EA" << -1 << "" << "" << true << false;
QTest::newRow("2E3") << "2E3" << "" << "" << "" << -1 << "" << "2E3" << "2E" << 3 << "" << "" << true << false;
QTest::newRow("E74") << "E74" << "" << "" << "" << -1 << "" << "E74" << "E7" << 4 << "" << "" << true << false;
QTest::newRow("A2") << "A2" << "" << "" << "" << -1 << "" << "A2" << "A2" << -1 << "" << "" << true << false;
Expand Down

0 comments on commit 368e72c

Please sign in to comment.