diff --git a/src/callsign.cpp b/src/callsign.cpp index 83f1e5b2..8d4909bd 100644 --- a/src/callsign.cpp +++ b/src/callsign.cpp @@ -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 { @@ -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("^(?(?%1)(?[0-9]*)|(?B|F|G|I|K|M|N|R|U|W|[A-Z][0-9]|[A-Z]{1,2}|[0-9][A-Z])(?[0-9]*))$").arg(aux); + return QString("^(?(?%1)(?[0-9]*)|(?B|F|G|I|K|M|N|R|U|W|[A-Z][0-9]|[A-Z]{1,2}|[0-9][A-Z])(?[0-9]*))").arg(aux); } QString Callsign::getSpecialPrefixes() @@ -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;} diff --git a/src/inputwidgets/mainwindowinputothers.cpp b/src/inputwidgets/mainwindowinputothers.cpp index cf1fb55e..f79c3f06 100644 --- a/src/inputwidgets/mainwindowinputothers.cpp +++ b/src/inputwidgets/mainwindowinputothers.cpp @@ -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 diff --git a/tests/tst_callsign/tst_callsign.cpp b/tests/tst_callsign/tst_callsign.cpp index 88070b63..61797ddf 100644 --- a/tests/tst_callsign/tst_callsign.cpp +++ b/tests/tst_callsign/tst_callsign.cpp @@ -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;