Skip to content

Commit

Permalink
subdivisions without main prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ea4k committed Aug 17, 2024
1 parent dcacd6f commit d4604ae
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 15 deletions.
36 changes: 26 additions & 10 deletions src/inputwidgets/mainwindowinputothers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,28 +767,44 @@ void MainWindowInputOthers::updatePrimarySubdivisionsComboBox(QList<PrimarySubdi

void MainWindowInputOthers::updatePrimarySubDivisions(const int _n, const QString &_qrz)
{
//qDebug() << Q_FUNC_INFO << " - Start: " << QString::number(_n) << "/" << _qrz;
currentPref = _qrz;
QString currentPrefTMP = util->getPrefixFromCall(_qrz, !showAllCheckBox->isChecked());
QString mainPref = dataProxy->getEntityMainPrefix(_n);
//qDebug() << Q_FUNC_INFO << " - currentPref: " << QString::number(_n) << "/" << currentPrefTMP;
int a = util->getAreaNumberFromCall(_qrz);
qDebug() << Q_FUNC_INFO << " - Start: " << QString::number(_n) << "/" << _qrz;
if (_n<1)
return;
currentInt = _n;
setEntity(_n);

currentPref = _qrz;
QString mainPref = dataProxy->getEntityMainPrefix(_n);
int areaNumber = util->getAreaNumberFromCall(_qrz);
qDebug() << Q_FUNC_INFO << " - AreaNumber: " << QString::number(areaNumber);
if (areaNumber>=0)
{
mainPref.append(QString::number(areaNumber));
// mainPref = mainPref + QString::number(areaNumber);
qDebug() << Q_FUNC_INFO << " - NEW mainPref: " << mainPref;
}

QString currentPrefTMP = util->getPrefixFromCall(_qrz, !showAllCheckBox->isChecked());

qDebug() << Q_FUNC_INFO << " - currentPref: " << QString::number(_n) << "/" << currentPrefTMP;
qDebug() << Q_FUNC_INFO << " - mainPref: " << QString::number(_n) << "/" << mainPref;


setEntity(currentInt);
if ((currentPrefTMP.isEmpty()) && (mainPref.isEmpty()))
return;

QList<PrimarySubdivision> subdivisions;
subdivisions.clear();
subdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, currentPrefTMP));
if (subdivisions.isEmpty())
if (subdivisions.length()<1)
{
qDebug() << Q_FUNC_INFO << " - Subdivisions is empty, running for the main prefix";
subdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, mainPref));
if (subdivisions.isEmpty())
//qDebug() << Q_FUNC_INFO << " - Subdivisions is empty, running just with the entity";
if (subdivisions.length()<1)
{
qDebug() << Q_FUNC_INFO << " - Subdivisions is empty, running just with the entity";
subdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, QString()));
}
}

//qDebug() << Q_FUNC_INFO << " - count: " << QString::number(subdivisions.count());
Expand Down
21 changes: 16 additions & 5 deletions src/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1113,9 +1113,11 @@ int Utilities::getAreaNumberFromCall(const QString &_c)

QString areaString = withAreaNumberPref.remove(withOutAreaNumberPref);
qDebug() << Q_FUNC_INFO << ": Area Number: " << areaString;
int areaNumber = -1;

return areaNumber;
bool ok = false;
int areaNumber = areaString.toInt(&ok, 10);
if (ok)
return areaNumber;
return -1;
}

QString Utilities::getPrefixFromCall(const QString &_c, bool withAreaNumber)
Expand Down Expand Up @@ -1164,7 +1166,7 @@ QString Utilities::getPrefixFromCall(const QString &_c, bool withAreaNumber)
{
//qDebug() << Q_FUNC_INFO << QString(" While (i=%1) = ").arg(i) << call;
if (isAKnownPrefix(call))
{// EA, EA6, VK9N, VP2E, K, K1, KN1, 4U1I
{// EA, EA6, VK9N, VP2E, K, K1, KN1, 4U1I, W6 (W6 and other normal prefix are also a known prefix due to the specific CQ/ITU)
//qDebug() << Q_FUNC_INFO << QString("- Known prefix found: %1").arg(call);
if (withAreaNumber)
{
Expand All @@ -1179,9 +1181,18 @@ QString Utilities::getPrefixFromCall(const QString &_c, bool withAreaNumber)
//qDebug() << Q_FUNC_INFO << QString("- With Area number -call3- & last is a digit");
return call3;
}
return call;
}
else
{ // Here I am receiving known prefixes and I need to remove the area number
if ( !((call.back()).isDigit()) )
{
qDebug() << Q_FUNC_INFO << QString("- Without Area number -call- & last is NOT a digit: %1").arg(call);
return call;
}
}
//qDebug() << Q_FUNC_INFO << QString("- With NO Area number");
return call;

}
//qDebug() << Q_FUNC_INFO << QString("- Known prefix NOT found: %1").arg(call);
call3 = call2;
Expand Down

0 comments on commit d4604ae

Please sign in to comment.