Skip to content

Commit

Permalink
Removing deprecated calls to Util::isValidCall
Browse files Browse the repository at this point in the history
  • Loading branch information
ea4k committed Dec 29, 2024
1 parent f434a0d commit 668c895
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 51 deletions.
9 changes: 6 additions & 3 deletions src/adif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*****************************************************************************/
//#include "global.h"
#include "adif.h"
#include "callsign.h"

Adif::Adif(const QString &_parentName)
{
Expand Down Expand Up @@ -695,9 +696,11 @@ QString Adif::getADIFField(const QString &_fieldName, const QString &_data)

bool Adif::isValidCall(const QString &_c)
{
if (_c.length ()>=3)
return true;
return false;
Callsign _callsign(_c);
return _callsign.isValid();
//if (_c.length ()>=3)
// return true;
//return false;
}

void Adif::logEvent(const QString &_func, const QString &_msg, DebugLogLevel _level)
Expand Down
5 changes: 4 additions & 1 deletion src/elogqrzlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*****************************************************************************/

#include "elogqrzlog.h"
#include "callsign.h"
#include <QCoreApplication>
#include <QUrl>
#include <QNetworkRequest>
Expand Down Expand Up @@ -579,7 +580,9 @@ void eLogQrzLog::checkQRZ(const QString &_qrz)
{
//qDebug() << Q_FUNC_INFO << ": " + _qrz;
showDebugLog (Q_FUNC_INFO, "Start: " + _qrz);
if (!util->isValidCall(_qrz))
Callsign _callsign(_qrz);
if (!_callsign.isValid())
//if (!util->isValidCall(_qrz))
{
//qDebug()<< "eLogQrzLog::checkQRZ: CALL not valid" ;
showDebugLog (Q_FUNC_INFO, "CALL not valid");
Expand Down
31 changes: 20 additions & 11 deletions src/filemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* *
*****************************************************************************/
#include "filemanager.h"
#include "callsign.h"
//#include <QDebug>


Expand Down Expand Up @@ -170,7 +171,9 @@ QList<int> FileManager::adifLogExportReturnList(const QString& _fileName, const
//qDebug() << Q_FUNC_INFO << ": Start)" << _fileName << "/" << _callsign << "/ " << _grid;
QList<int> qsos;
qsos.clear();
if ((!util->isValidCall(_callsign)) && (_callsign != "ALL") && (_callsign !="NOT"))
Callsign _call(_callsign);

if ((!_call.isValid()) && (_callsign != "ALL") && (_callsign !="NOT"))
{
showError(tr("The selected callsign (%1) is not valid, please check it again to export the log.").arg(_callsign));
return qsos;
Expand Down Expand Up @@ -433,7 +436,8 @@ QList<int> FileManager::adifLogExportReturnList2(const QString& _fileName, const
//qDebug() << Q_FUNC_INFO << ": Start)" << _fileName << "/" << _callsign << "/ " << _grid;
QList<int> qsos;
qsos.clear();
if ((!util->isValidCall(_callsign)) && (_callsign != "ALL") && (_callsign !="NOT"))
Callsign _call(_callsign);
if ((!_call.isValid()) && (_callsign != "ALL") && (_callsign !="NOT"))
{
showError(tr("The selected callsign (%1) is not valid, please check it again to export the log.").arg(_callsign));
return qsos;
Expand Down Expand Up @@ -971,7 +975,8 @@ int FileManager::adifLoTWReadLog2(const QString& fileName, const int logN)
if (line.contains("OWNCALL:"))
{
stationCallSign = (line.section(": ", 1, 1)).simplified();
if (!util->isValidCall(stationCallSign))
Callsign _call(stationCallSign);
if (!_call.isValid())
{
stationCallSign = QString();
}
Expand Down Expand Up @@ -1051,7 +1056,9 @@ int FileManager::adifReadLog2(const QString& tfileName, QString _stationCallsign
{
//qDebug() << Q_FUNC_INFO << QString(": EOR detected, QSO added");
qso.setLogId (logN);
if ((util->isValidCall(_stationCallsign,true)) && (!util->isValidCall(qso.getStationCallsign(), true)) )
Callsign _call1(_stationCallsign);
Callsign _call2(qso.getStationCallsign());
if (_call1.isValid() && (!_call2.isValid()) )
{
qso.setStationCallsign(_stationCallsign);
}
Expand Down Expand Up @@ -1292,10 +1299,11 @@ bool FileManager::getStationCallsignFromUser(const QString &_qrzDX, const QDate
{
_date = ", on "+ util->getDateSQLiteStringFromDate(_dt) ;
}

if (util->isValidCall(_qrzDX))
Callsign _callsign(_qrzDX);
if (_callsign.isValid())
//if (util->isValidCall(_qrzDX))
{
aux = tr("KLog has found one QSO without the Station Callsign defined.\n\nEnter the Station Callsign that was used to do this QSO with %1 on %2:").arg(_qrzDX).arg(_date);
aux = tr("KLog has found one QSO without the Station Callsign defined.\n\nEnter the Station Callsign that was used to do this QSO with %1 on %2:").arg(_callsign.getCallsign()).arg(_date);
text = QInputDialog::getText(this, tr("KLog - QSO without Station Callsign"),
aux, QLineEdit::Normal, "", &ok);
}
Expand All @@ -1305,8 +1313,8 @@ bool FileManager::getStationCallsignFromUser(const QString &_qrzDX, const QDate
tr("KLog has found one QSO without the Station Callsign defined.\n\nEnter the Station Callsign that was used to do this QSO on %1:").arg(_date), QLineEdit::Normal,
"", &ok);
}

if (ok && util->isValidCall(text))
Callsign call2(text);
if (ok && call2.isValid())
{
defaultStationCallsign = text.toUpper();
return true;
Expand Down Expand Up @@ -1711,10 +1719,11 @@ bool FileManager::writeBackupDate()
void FileManager::setStationCallSign(const QString& _st)
{
//qDebug() << "FileManager::setStationCallSign: " << _st;
if (util->isValidCall(_st))
Callsign _callsign(_st);
if (_callsign.isValid())
{
//qDebug() << "FileManager::setStationCallSign: True";
defaultStationCallsign = _st;
defaultStationCallsign = _callsign.getCallsign();
//qDebug() << "FileManager::setStationCallSign: " << defaultStationCallsign;
}
else
Expand Down
5 changes: 4 additions & 1 deletion src/lotwutilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*****************************************************************************/

#include "lotwutilities.h"
#include "callsign.h"
#include <QCoreApplication>
#include <QUrl>
#include <QNetworkRequest>
Expand Down Expand Up @@ -146,7 +147,9 @@ bool LoTWUtilities::selectQuery(const int _queryId)
bool LoTWUtilities::setStationCallSign(const QString &_call)
{
//qDebug() << "LoTWUtilities::setStationCallSign: " << _call;
if (!util->isValidCall(_call))
Callsign _callsign(_call);
if (!_callsign.isValid())
//if (!util->isValidCall(_call))
{
//qDebug() << "LoTWUtilities::setStationCallSign: FALSE 1" ;
return false;
Expand Down
5 changes: 4 additions & 1 deletion src/mainqsoentrywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*****************************************************************************/
//https://github.com/ea4k/klog/commit/1ac02c7b779922a8e5907ebee088fa64654cbdf5
#include "mainqsoentrywidget.h"
#include "callsign.h"

MainQSOEntryWidget::MainQSOEntryWidget(DataProxy_SQLite *dp, QWidget *parent) : QWidget(parent)
{
Expand Down Expand Up @@ -300,7 +301,9 @@ void MainQSOEntryWidget::slotQRZTextChanged()
//TODO: This validCharactersInCall may be removed?
InValidCharsInPrevCall = validCharactersInCall(qrzLineEdit->text());
//qDebug()<< "MainQSOEntryWidget::slotQRZTextChanged: checking for invalid chars 00 ";
if (!util->isValidCall(qrzLineEdit->text()))
Callsign _callsign(qrzLineEdit->text());
if (!_callsign.isValid())
//if (!util->isValidCall(qrzLineEdit->text()))
{
qrzLineEdit->setPalette(palRed);
//emit showInfoLabel(tr("Callsign not valid"));
Expand Down
78 changes: 48 additions & 30 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1204,14 +1204,16 @@ bool MainWindow::readQSOFromUI()
logEvent(Q_FUNC_INFO, "Start", Debug);

qso->clear ();
QString tqrz = (mainQSOEntryWidget->getQrz()).toUpper();
//QString tqrz = (mainQSOEntryWidget->getQrz()).toUpper();
Callsign _callsign(mainQSOEntryWidget->getQrz());
if (!_callsign.isValid())

if (!util->isValidCall(tqrz))
//if (!util->isValidCall(tqrz))
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - Not valid call"));
QString aux = QString(tr("The callsign %1 is not a valid call. Do you really want to add this callsign to the log?") ).arg(tqrz);
QString aux = QString(tr("The callsign %1 is not a valid call. Do you really want to add this callsign to the log?") ).arg(mainQSOEntryWidget->getQrz());
msgBox.setText(aux);
msgBox.setInformativeText(tr("Adding non-valid calls to the log may create problems when applying for awards, exporting ADIF files to other systems or applications."));
msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
Expand All @@ -1230,7 +1232,7 @@ bool MainWindow::readQSOFromUI()
break;
}
}
qso->setCall (tqrz);
qso->setCall (_callsign.getCallsign());
qso->setBand(mainQSOEntryWidget->getBand());
qso->setMode(dataProxy->getNameFromSubMode (mainQSOEntryWidget->getMode()));
qso->setSubmode (mainQSOEntryWidget->getMode());
Expand All @@ -1243,8 +1245,8 @@ bool MainWindow::readQSOFromUI()
qso->setRSTTX (QSOTabWidget->getRSTTX ());
qso->setRSTRX (QSOTabWidget->getRSTRX ());

int dxcc = world->getQRZARRLId(tqrz);
//qDebug() << Q_FUNC_INFO + QString(": %1 - %2").arg(tqrz).arg(dxcc);
int dxcc = world->getQRZARRLId(_callsign.getCallsign());
//qDebug() << Q_FUNC_INFO + QString(": %1 - %2").arg(_callsign.getCallsign()).arg(dxcc);

//int dxcc2 = getDXCCFromComboBox();
int dxcc2 = othersTabWidget->getEntity();
Expand Down Expand Up @@ -2960,11 +2962,13 @@ QString MainWindow::selectStationCallsign()
stationCallToUse = QInputDialog::getItem(this, tr("Station Callsign:"),
msg, stationCallSigns, 0, false, &ok);

if (ok && util->isValidCall(stationCallToUse))
Callsign _callsign(stationCallToUse);
//if (_callsign.isValid())
if (ok && _callsign.isValid())
//if (ok && !stationCallToUse.isEmpty())
{
logEvent(Q_FUNC_INFO, "END-1", Debug);
return stationCallToUse;
return _callsign.getCallsign();
}
else
{
Expand All @@ -2974,10 +2978,12 @@ QString MainWindow::selectStationCallsign()
if (ok)
{
//callsignTyped = true;
if (util->isValidCall(stationCallToUse))
Callsign _callsign2(stationCallToUse);
if (_callsign2.isValid())
//if (util->isValidCall(stationCallToUse))
{
logEvent(Q_FUNC_INFO, "END-2", Debug);
return stationCallToUse;
return _callsign2.getCallsign();
}
}
else
Expand Down Expand Up @@ -3062,8 +3068,9 @@ void MainWindow::slotReceiveQSOListToShowFromFile(QStringList _qs)
//qDebug() << Q_FUNC_INFO << " - NO valid qso list received - length: " << QString::number(_qs.length()) ;
return;
}

if (!util->isValidCall(_qs.at(0)))
Callsign _callsign(_qs.at(0));
if (!_callsign.isValid())
//if (!util->isValidCall(_qs.at(0)))
{
//qDebug() << Q_FUNC_INFO << " - NO valid QRZ received - " << _qs.at(0) ;
return;
Expand Down Expand Up @@ -4032,8 +4039,10 @@ void MainWindow::fileExportLoTW2(const QString &_call, QList<int> _qsos)
}

QMessageBox msgBox;
Callsign _callsign(_call);
if (!_callsign.isValid())

if (!util->isValidCall(_call))
//if (!util->isValidCall(_call))
{
//qDebug() << Q_FUNC_INFO << " - no valid call" ;
if (_call == "ALL")
Expand Down Expand Up @@ -4118,9 +4127,10 @@ void MainWindow::fileExportClubLog2(const QString &_call, QList<int> _qsos)
{
//qDebug() << Q_FUNC_INFO << QString(" - Start: %1 / QSOs: %2" ).arg(_call).arg(_qsos.length ());
QMessageBox msgBox;

if (!util->isValidCall(_call))
{
Callsign _callsign(_call);
if (!_callsign.isValid())
//if (!util->isValidCall(_call))
{
//qDebug() << Q_FUNC_INFO << " - no valid call" ;
if (_call == "ALL")
{
Expand Down Expand Up @@ -5365,10 +5375,11 @@ void MainWindow::slotAnalyzeDxClusterSignal(const DXSpot &_spot)


pQSO.status = awards->getQSOStatus(statusI);

if (util->isValidCall(sp.getDxCall(), true))
Callsign _callsign(sp.getDxCall());
if (_callsign.isValid())
//if (util->isValidCall(sp.getDxCall(), true))
{
pQSO.call = sp.getDxCall();
pQSO.call = _callsign.getCallsign();
dxClusterAssistant->newDXClusterSpot(pQSO);
}

Expand All @@ -5384,11 +5395,12 @@ void MainWindow::slotDXClusterSpotArrived(const DXSpot &_spot)
DXSpot sp = _spot;
if (!sp.isValid())
return;

if (util->isValidCall(sp.getDxCall(), true))
Callsign _callsign(sp.getDxCall());
if (_callsign.isValid())
//if (util->isValidCall(sp.getDxCall(), true))
{
proposedQSOs pQSO;
pQSO.call = sp.getDxCall();
pQSO.call = _callsign.getCallsign();
pQSO.status = ATNO;
pQSO.freq = sp.getFrequency();
dxClusterAssistant->newDXClusterSpot(pQSO);
Expand Down Expand Up @@ -5492,9 +5504,11 @@ void MainWindow::updateQSLRecAndSent()

QString MainWindow::findStationCallsignToUse()
{
QString foundCall = dataProxy->getStationCallSignFromLog (currentLog);
if (util->isValidCall(foundCall))
return foundCall;
//QString foundCall = dataProxy->getStationCallSignFromLog (currentLog);
Callsign _callsign(dataProxy->getStationCallSignFromLog (currentLog));
if (_callsign.isValid())
//if (util->isValidCall(foundCall))
return _callsign.getCallsign();

return mainQRZ;
}
Expand All @@ -5503,13 +5517,15 @@ void MainWindow::defineStationCallsign()
{

logEvent(Q_FUNC_INFO, "Start", Debug);
QString logQRZ = findStationCallsignToUse();
//QString logQRZ = findStationCallsignToUse();
//qDebug() << Q_FUNC_INFO << ": StationCallsign: " << logQRZ;
if (!util->isValidCall (logQRZ))
Callsign _callsign(findStationCallsignToUse());
if (!_callsign.isValid())
//if (!util->isValidCall (logQRZ))
{
return;
}
stationCallsign = logQRZ;
stationCallsign = _callsign.getCallsign();

//qDebug() << Q_FUNC_INFO << ": " << stationCallsign ;

Expand Down Expand Up @@ -6533,9 +6549,11 @@ bool MainWindow::loadSettings()
settings.beginGroup ("UserData");
value = settings.value ("Callsign").toString ();
//qDebug() << Q_FUNC_INFO << " stationCallSign: " << value;
if (util->isValidCall(value))
Callsign _callsign(value);
if (_callsign.isValid())
//if (util->isValidCall(value))
{
mainQRZ = value;
mainQRZ = _callsign.getCallsign();
}
// We Select the log after the mainQRZ is defined to prevent call conflicts
selectTheLog(currentLog);
Expand Down
7 changes: 5 additions & 2 deletions src/searchwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*****************************************************************************/

#include "searchwidget.h"
#include "callsign.h"

SearchWidget::SearchWidget(DataProxy_SQLite *dp, QWidget *parent) :
QWidget(parent)
Expand Down Expand Up @@ -143,9 +144,11 @@ void SearchWidget::showQSOs(QList<int> qsoIdList)

void SearchWidget::setStationCallsign(const QString &_st)
{
if (util->isValidCall(_st))
Callsign _callsign(_st);
if (_callsign.isValid())
//if (util->isValidCall(_st))
{
mainStationCallsign = _st;
mainStationCallsign = _callsign.getCallsign();
selectStationCallSign();
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/tst_adif/tst_adif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include <QtTest>
#include "../../src/adif.h"

#include "../../src/callsign.h"

class tst_Adif : public QObject
{
Expand Down
Loading

0 comments on commit 668c895

Please sign in to comment.