示例#1
0
/*!
   KQP exchange validator
 */
bool KQP::validateExchange(Qso *qso)
{
    if (!separateExchange(qso)) return(false);

    qso->bandColumn=qso->band;
    for (int ii = 0; ii < MMAX; ii++) qso->mult[ii] = -1;

    // check prefix
    determineMultType(qso);

    // any number must be RST; take last one entered
    int nrField=-1;
    bool ok_part[2];
    ok_part[0]=false;
    ok_part[1]=false;
    for (int i=exchElement.size()-1;i>=0;i--) {
        bool ok=false;
        exchElement.at(i).toInt(&ok);
        if (ok) {
            nrField=i;
            ok_part[0]=true;
            break;
        }
    }
    if (nrField!=-1) {
        finalExch[0]=exchElement.at(nrField);
    } else {
        // default RST
        if (qso->modeType==CWType || qso->modeType==DigiType) {
            finalExch[0]="599";
        } else {
            finalExch[0]="59";
        }
        ok_part[0]=true;
    }

    // look for state or KS county

    // both KS and non-KS can work stations with county mults
    int m=-1;
    int multField=-1;
    if (qso->isamult[0]) {
        for (int i=exchElement.size()-1;i>=0;i--) {
            m=isAMult(exchElement.at(i),0);
            if (m!=-1) {
                ok_part[1]=true;
                qso->mult[0]=m;
                multField=i;
                break;
            }
        }
        // special case: KS stations get the "KS" mult for any KS county worked
        if (withinState) {
            if (ok_part[1]) {
                qso->isamult[1]=true;
               // qso->isamult[0]=false;
                qso->mult[1]=0;
               // qso->mult[0]=-1; // don't count as a county mult
                qso->newmult[0]=false;
            }
        }
    }
    // non-KS only works KS
    if (withinState) {
        // KS station mults
        // check first for DX:
        for (int i=exchElement.size()-1;i>=0;i--) {
            // ignore any 'KS' entered here
            if (exchElement.at(i)=="KS") continue;

            m=isAMult(exchElement.at(i),1);
            if (m!=-1) {
                ok_part[1]=true;
                qso->mult[1]=m;
                multField=i;
                break;
            }
        }
        if (ok_part[1]) {
            finalExch[1]=exchElement.at(multField);
        }

        // only copy into log if exchange is validated
        if (ok_part[0] && ok_part[1]) {
            for (int i = 0; i < nExch; i++) {
                qso->rcv_exch[i] = finalExch[i];
            }
        }
    }
    // if exchange is ok and a mobile, we need a mobile dupe check
    if (qso->isMobile && ok_part[0] && ok_part[1]) {
        emit(mobileDupeCheck(qso));
        if (!qso->dupe) {
            emit(clearDupe());
        }
    }
    return(ok_part[0] && ok_part[1]);
}
示例#2
0
/*!
   PAQP exchange validator

   mult 0: PA counties
   mult 1: ARRL/Canadian Sections
 */
bool PAQP::validateExchange(Qso *qso)
{
    if (!separateExchange(qso)) return(false);

    for (int ii = 0; ii < MMAX; ii++) qso->mult[ii] = -1;

    // check prefix
    determineMultType(qso);

    // any number must be qso number; take last one entered
    int nrField=-1;
    bool ok_part[2];
    ok_part[0]=false;
    ok_part[1]=false;
    for (int i=exchElement.size()-1;i>=0;i--) {
        bool ok=false;
        exchElement.at(i).toInt(&ok);
        if (ok) {
            nrField=i;
            ok_part[0]=true;
            break;
        }
    }
    if (nrField!=-1) {
        finalExch[0]=exchElement.at(nrField);
    }

    // look for section or PA county

    // both PA and non-PA have county mults
    int m=-1;
    int multField=-1;
    if (qso->isamult[0]) {
        for (int i=exchElement.size()-1;i>=0;i--) {
            m=isAMult(exchElement.at(i),0);
            if (m!=-1) {
                ok_part[1]=true;
                qso->mult[0]=m;
                multField=i;
                break;
            }
        }
        // special case: PA stations get the "WPA" or "EPA" mult for PA county worked
        if (withinState) {
            if (ok_part[1]) {
                if (EPA_counties.contains(exchElement.at(multField)))
                       qso->mult[1]=0; // EPA
                else
                       qso->mult[1]=1; // WPA
            }
        }
    }
    // non-PA only works PA
    if (!withinState) {
        if (!ok_part[1]) return(false);
    }

    // PA also gets mults for sections; can also work DX

    // check first for DX:
    if (!qso->isamult[1]) {
        finalExch[1]="DX";
        ok_part[1]=true;
    } else {
        for (int i=exchElement.size()-1;i>=0;i--) {
            // ignore any 'WPA' or 'EPA' entered here
            if (exchElement.at(i)=="EPA" || exchElement.at(i)=="WPA") continue;

            m=isAMult(exchElement.at(i),1);
            if (m!=-1) {
                ok_part[1]=true;
                qso->mult[1]=m;
                multField=i;
            break;
            }
        }
        if (ok_part[1]) {
            finalExch[1]=exchElement.at(multField);
        }
    }

    // only copy into log if exchange is validated
    if (ok_part[0] && ok_part[1]) {
        for (int i = 0; i < nExch; i++) {
            qso->rcv_exch[i] = finalExch[i];
        }
    }
    // if exchange is ok and a mobile, we need a mobile dupe check
    if (qso->isMobile && ok_part[0] && ok_part[1]) {
        emit(mobileDupeCheck(qso));
        if (!qso->dupe) {
            emit(clearDupe());
        }
    }
    return(ok_part[0] && ok_part[1]);
}