diff --git a/src/callsign.h b/src/callsign.h index 8ca5b45f..7664b142 100644 --- a/src/callsign.h +++ b/src/callsign.h @@ -77,10 +77,10 @@ class Callsign : public QObject void clear(); private: - static QString callsignRegExString(); - static QRegularExpression callsignRegEx(); - static QString prefixRegExString(); - static QRegularExpression prefixRegEx(); + static QString callsignRegExString(); + static QRegularExpression callsignRegEx(); + static QString prefixRegExString(); + static QRegularExpression prefixRegEx(); QString fullCall; // K1/EA4K/QRP QString hostFullPrefix; // K1 diff --git a/src/qso.cpp b/src/qso.cpp index a503b844..6a67947c 100644 --- a/src/qso.cpp +++ b/src/qso.cpp @@ -26,6 +26,7 @@ #include "qso.h" #include "QtSql/qsqlerror.h" #include "qsqlrecord.h" +#include "callsign.h" QSO::QSO() { @@ -716,17 +717,13 @@ bool QSO::isValid() bool QSO::setCall(const QString &_c) { logEvent (Q_FUNC_INFO, QString("Start: %1").arg(_c), Debug); - QString aux; - aux = _c.toUpper(); - if ((aux.isNull()) || (aux.length()<3)) - { - logEvent(Q_FUNC_INFO, "END - False-1", Debug); - return false; - } - if (util->isValidCall(aux)) + + Callsign _callsign (_c); + if (_callsign.isValid()) + //if (util->isValidCall(aux)) { logEvent (Q_FUNC_INFO, QString("END - true"), Debug); - callsign = aux; + callsign = _callsign.getCallsign(); haveCall = true; return true; } @@ -1751,14 +1748,12 @@ bool QSO::setOperatorCallsign(const QString &_c) { //qDebug() << Q_FUNC_INFO << "Start: " << _c; //logEvent(Q_FUNC_INFO, "Start", Debug); - QString aux = _c; - if (aux.length()<3) - return false; - - if (util->isValidCall(aux)) + Callsign _callsign (_c); + if (_callsign.isValid()) + //if (util->isValidCall(aux)) { - operatorCall = aux; + operatorCall = _callsign.getCallsign(); //qDebug() << Q_FUNC_INFO << "END - true"; logEvent(Q_FUNC_INFO, "END-true", Debug); return true; @@ -1779,18 +1774,14 @@ QString QSO::getOperatorCallsign() bool QSO::setStationCallsign(const QString &_c) { //qDebug() << Q_FUNC_INFO << "Start: " << _c; - QString aux = _c; - if ((aux.length()<3) || (aux.isNull())) - { - //qDebug() << Q_FUNC_INFO << " - 009"; - return false; - } + Callsign _callsign (_c); + if (_callsign.isValid()) //qDebug() << Q_FUNC_INFO << " - 010"; - if (util->isValidCall(aux)) + //if (util->isValidCall(aux)) { //qDebug() << Q_FUNC_INFO << " - True"; - stationCallsign = aux; + stationCallsign = _callsign.getCallsign(); return true; } else @@ -2046,7 +2037,9 @@ double QSO::getDistance() bool QSO::setOwnerCallsign(const QString &_c) { - if (util->isValidCall(_c)) + Callsign _callsign (_c); + if (_callsign.isValid()) + //if (util->isValidCall(_c)) { ownerCall = _c; return true; @@ -2063,7 +2056,9 @@ QString QSO::getOwnerCallsign() bool QSO::setEQ_Call(const QString &_c) { - if (util->isValidCall(_c)) + Callsign _callsign (_c); + if (_callsign.isValid()) + //if (util->isValidCall(_c)) { contacted_owner = _c; return true; @@ -2263,7 +2258,9 @@ QString QSO::getCounty() bool QSO::setContactedOperator(const QString &_c) { - if (util->isValidCall(_c)) + Callsign _callsign (_c); + if (_callsign.isValid()) + //if (util->isValidCall(_c)) { contacted_op = _c; return true; diff --git a/src/qso.h b/src/qso.h index 2081415e..c8cc25f6 100644 --- a/src/qso.h +++ b/src/qso.h @@ -35,6 +35,7 @@ //#include #include "global.h" #include "utilities.h" +#include "callsign.h" #include "klogdefinitions.h" #include "adif.h" //#include "database.h" diff --git a/tests/tst_qso/tst_qso.cpp b/tests/tst_qso/tst_qso.cpp index fcd07fd4..9f122888 100644 --- a/tests/tst_qso/tst_qso.cpp +++ b/tests/tst_qso/tst_qso.cpp @@ -28,6 +28,7 @@ #include #include "../../src/qso.h" +#include "../../src/callsign.h" #include "../../src/klogdefinitions.h" diff --git a/tests/tst_qso/tst_qso.pro b/tests/tst_qso/tst_qso.pro index 86ca7b0a..b14b8f39 100644 --- a/tests/tst_qso/tst_qso.pro +++ b/tests/tst_qso/tst_qso.pro @@ -9,6 +9,7 @@ TEMPLATE = app HEADERS += \ ../../src/utilities.h \ + ../../src/callsign.h \ ../../src/global.h \ ../../src/klogdefinitions.h \ #../../src/dataproxy_sqlite.h \ @@ -19,6 +20,7 @@ HEADERS += \ SOURCES += tst_qso.cpp \ ../../src/utilities.cpp \ + ../../src/callsign.cpp \ #../../src/dataproxy_sqlite.cpp \ #../../src/database.cpp \ ../../src/locator.cpp \