From ac94690a9c836baec245a83222e3c723b253004f Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Mon, 1 Oct 2018 14:12:44 -0400 Subject: [PATCH 1/4] Disable two diagnostics. Add files to wsjtx.pro. --- decodedtext.cpp | 2 +- displaytext.cpp | 2 +- wsjtx.pro | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/decodedtext.cpp b/decodedtext.cpp index 8bf59e715..f466bb8d9 100644 --- a/decodedtext.cpp +++ b/decodedtext.cpp @@ -20,7 +20,7 @@ DecodedText::DecodedText (QString const& the_string) , message_ {string_.mid (column_qsoText + padding_).trimmed ()} , is_standard_ {false} { - qDebug () << "DecodedText: the_string:" << the_string << "Nbsp pos:" << the_string.indexOf (QChar::Nbsp); +// qDebug () << "DecodedText: the_string:" << the_string << "Nbsp pos:" << the_string.indexOf (QChar::Nbsp); if (message_.length() >= 1) { message0_ = message_.left(36); diff --git a/displaytext.cpp b/displaytext.cpp index 664564fad..f27e7da43 100644 --- a/displaytext.cpp +++ b/displaytext.cpp @@ -76,7 +76,7 @@ void DisplayText::insertLineSpacer(QString const& line) void DisplayText::appendText(QString const& text, QColor bg, QString const& call1, QString const& call2) { - qDebug () << "DisplayText::appendText: text:" << text << "Nbsp pos:" << text.indexOf (QChar::Nbsp); +// qDebug () << "DisplayText::appendText: text:" << text << "Nbsp pos:" << text.indexOf (QChar::Nbsp); auto cursor = textCursor (); cursor.movePosition (QTextCursor::End); auto block_format = cursor.blockFormat (); diff --git a/wsjtx.pro b/wsjtx.pro index 353bd4aea..3d16edf02 100644 --- a/wsjtx.pro +++ b/wsjtx.pro @@ -67,8 +67,7 @@ SOURCES += \ echoplot.cpp echograph.cpp fastgraph.cpp fastplot.cpp Modes.cpp \ WSPRBandHopping.cpp MessageAggregator.cpp SampleDownloader.cpp qt_helpers.cpp\ MultiSettings.cpp PhaseEqualizationDialog.cpp IARURegions.cpp MessageBox.cpp \ - EqualizationToolsDialog.cpp \ - colorhighlighting.cpp + EqualizationToolsDialog.cpp CallsignValidator.cpp colorhighlighting.cpp HEADERS += qt_helpers.hpp \ pimpl_h.hpp pimpl_impl.hpp \ @@ -84,8 +83,7 @@ HEADERS += qt_helpers.hpp \ logbook/logbook.h logbook/countrydat.h logbook/countriesworked.h logbook/adif.h \ messageaveraging.h echoplot.h echograph.h fastgraph.h fastplot.h Modes.hpp WSPRBandHopping.hpp \ WsprTxScheduler.h SampleDownloader.hpp MultiSettings.hpp PhaseEqualizationDialog.hpp \ - IARURegions.hpp MessageBox.hpp EqualizationToolsDialog.hpp \ - colorhighlighting.h + IARURegions.hpp MessageBox.hpp EqualizationToolsDialog.hpp CallsignValidator.hpp colorhighlighting.h INCLUDEPATH += qmake_only From 1fbc51ddd91bfe8193e966de1e1be18021bb4e74 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Mon, 1 Oct 2018 14:14:47 -0400 Subject: [PATCH 2/4] Add exch_valid.f90, a Fortran validator for FD and RU exchanges. --- CMakeLists.txt | 1 + lib/77bit/exch_valid.f90 | 61 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 lib/77bit/exch_valid.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index 83100946f..9565c5060 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -411,6 +411,7 @@ set (wsjt_FSRCS lib/ft8/encode174_91.f90 lib/entail.f90 lib/ephem.f90 + lib/77bit/exch_valid.f90 lib/extract.f90 lib/extract4.f90 lib/extractmessage144.f90 diff --git a/lib/77bit/exch_valid.f90 b/lib/77bit/exch_valid.f90 new file mode 100644 index 000000000..70613fc9a --- /dev/null +++ b/lib/77bit/exch_valid.f90 @@ -0,0 +1,61 @@ +logical*1 function exch_valid(ntype,exch) + + parameter (NSEC=84) !Number of ARRL Sections + parameter (NUSCAN=65) !Number of US states and Canadian provinces + + character*(*) exch + character*3 c3 + character*3 cmult(NUSCAN) + character*3 csec(NSEC) + + data csec/ & + "AB ","AK ","AL ","AR ","AZ ","BC ","CO ","CT ","DE ","EB ", & + "EMA","ENY","EPA","EWA","GA ","GTA","IA ","ID ","IL ","IN ", & + "KS ","KY ","LA ","LAX","MAR","MB ","MDC","ME ","MI ","MN ", & + "MO ","MS ","MT ","NC ","ND ","NE ","NFL","NH ","NL ","NLI", & + "NM ","NNJ","NNY","NT ","NTX","NV ","OH ","OK ","ONE","ONN", & + "ONS","OR ","ORG","PAC","PR ","QC ","RI ","SB ","SC ","SCV", & + "SD ","SDG","SF ","SFL","SJV","SK ","SNJ","STX","SV ","TN ", & + "UT ","VA ","VI ","VT ","WCF","WI ","WMA","WNY","WPA","WTX", & + "WV ","WWA","WY ","DX "/ + data cmult/ & + "AL ","AK ","AZ ","AR ","CA ","CO ","CT ","DE ","FL ","GA ", & + "HI ","ID ","IL ","IN ","IA ","KS ","KY ","LA ","ME ","MD ", & + "MA ","MI ","MN ","MS ","MO ","MT ","NE ","NV ","NH ","NJ ", & + "NM ","NY ","NC ","ND ","OH ","OK ","OR ","PA ","RI ","SC ", & + "SD ","TN ","TX ","UT ","VT ","VA ","WA ","WV ","WI ","WY ", & + "NB ","NS ","QC ","ON ","MB ","SK ","AB ","BC ","NWT","NF ", & + "LB ","NU ","YT ","PEI","DC "/ + + exch_valid=.false. + n=len(trim(exch)) + if(ntype.ne.3 .and. ntype.ne.4) go to 900 + if(ntype.eq.3 .and. (n.lt.2 .or. n.gt.7)) go to 900 + if(ntype.eq.4 .and. (n.lt.2 .or. n.gt.3)) go to 900 + + if(ntype.eq.3) then !Field Day + i1=index(exch,' ') + if(i1.lt.3) go to 900 + read(exch(1:i1-2),*,err=900) ntx + if(ntx.lt.1 .or. ntx.gt.32) go to 900 + if(exch(i1-1:i1-1).lt.'A' .or. exch(i1-1:i1-1).gt.'F') go to 900 + c3=exch(i1+1:)//' ' + do i=1,NSEC + if(csec(i).eq.c3) then + exch_valid=.true. + go to 900 + endif + enddo + + else if(ntype.eq.4) then !RTTY Roundup + c3=exch//' ' + do i=1,NUSCAN + if(cmult(i).eq.c3) then + exch_valid=.true. + go to 900 + endif + enddo + endif + +900 return +end function exch_valid From cd8f13b57d1c35774ec3d3b37119639cc6825341 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Mon, 1 Oct 2018 16:48:36 -0400 Subject: [PATCH 3/4] Implement a validator for FD and RTTY exchange entries. --- CMakeLists.txt | 2 +- Configuration.cpp | 5 +-- ExchangeValidator.cpp | 67 ++++++++++++++++++++++++++++++++++++++++ ExchangeValidator.hpp | 19 ++++++++++++ lib/77bit/exch_valid.f90 | 61 ------------------------------------ mainwindow.cpp | 1 + wsjtx.pro | 6 ++-- 7 files changed, 95 insertions(+), 66 deletions(-) create mode 100644 ExchangeValidator.cpp create mode 100644 ExchangeValidator.hpp delete mode 100644 lib/77bit/exch_valid.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9565c5060..b5e872521 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -257,6 +257,7 @@ set (wsjt_qt_CXXSRCS MultiSettings.cpp MaidenheadLocatorValidator.cpp CallsignValidator.cpp + ExchangeValidator.cpp SplashScreen.cpp EqualizationToolsDialog.cpp DoubleClickablePushButton.cpp @@ -411,7 +412,6 @@ set (wsjt_FSRCS lib/ft8/encode174_91.f90 lib/entail.f90 lib/ephem.f90 - lib/77bit/exch_valid.f90 lib/extract.f90 lib/extract4.f90 lib/extractmessage144.f90 diff --git a/Configuration.cpp b/Configuration.cpp index ba9b74bcd..26425fca0 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -180,6 +180,7 @@ #include "MessageBox.hpp" #include "MaidenheadLocatorValidator.hpp" #include "CallsignValidator.hpp" +#include "ExchangeValidator.hpp" #include "ui_Configuration.h" #include "moc_Configuration.cpp" @@ -997,12 +998,12 @@ Configuration::impl::impl (Configuration * self, QDir const& temp_directory, // this must be done after the default paths above are set read_settings (); - // // validation - // ui_->callsign_line_edit->setValidator (new CallsignValidator {this}); ui_->grid_line_edit->setValidator (new MaidenheadLocatorValidator {this}); ui_->add_macro_line_edit->setValidator (new QRegExpValidator {message_alphabet, this}); + ui_->FieldDay_Exchange->setValidator(new ExchangeValidator{this}); + ui_->RTTY_Exchange->setValidator(new ExchangeValidator{this}); ui_->udp_server_port_spin_box->setMinimum (1); ui_->udp_server_port_spin_box->setMaximum (std::numeric_limits::max ()); diff --git a/ExchangeValidator.cpp b/ExchangeValidator.cpp new file mode 100644 index 000000000..e825d00ca --- /dev/null +++ b/ExchangeValidator.cpp @@ -0,0 +1,67 @@ +#include +#include "ExchangeValidator.hpp" + +ExchangeValidator::ExchangeValidator (QObject * parent) + : QValidator {parent} +{ +} + +auto ExchangeValidator::validate (QString& input, int& length) const -> State +{ + bool ok=false; + QStringList w=input.split(" "); + int nwords=w.size(); + length=input.size(); + input = input.toUpper (); + + if(nwords==1 and length<=3) { + //ARRL RTTY Roundup +// ntype=4; +// ok=exch_valid_(&ntype, const_cast(input.toLatin1().constData()),length); + QStringList states; + states << "AL" << "AK" << "AZ" << "AR" << "CA" << "CO" + << "CT" << "DE" << "FL" << "GA" << "HI" << "ID" + << "IL" << "IN" << "IA" << "KS" << "KY" << "LA" + << "ME" << "MD" << "MA" << "MI" << "MN" << "MS" + << "MO" << "MT" << "NE" << "NV" << "NH" << "NJ" + << "NM" << "NY" << "NC" << "ND" << "OH" << "OK" + << "OR" << "PA" << "RI" << "SC" << "SD" << "TN" + << "TX" << "UT" << "VT" << "VA" << "WA" << "WV" + << "WI" << "WY" << "NB" << "NS" << "QC" << "ON" + << "MB" << "SK" << "AB" << "BC" << "NWT" << "NF" + << "LB" << "NU" << "YT" << "PEI" << "DC" << "DX"; + if(states.contains(input)) ok=true; + + } + if(nwords==2 and w.at(1).size()<=3) { + //ARRL Field Day + int n=w.at(0).size(); + if(n>3) goto done; + int ntx=w.at(0).left(n-1).toInt(); + if(ntx<1 or ntx>32) goto done; + QString c1=w.at(0).right(1); + if(c1<"A" or c1>"F") goto done; + QStringList sections; + sections << "AB" << "AK" << "AL" << "AR" << "AZ" << "BC" + << "CO" << "CT" << "DE" << "EB" << "EMA" << "ENY" + << "EPA" << "EWA" << "GA" << "GTA" << "IA" << "ID" + << "IL" << "IN" << "KS" << "KY" << "LA" << "LAX" + << "MAR" << "MB" << "MDC" << "ME" << "MI" << "MN" + << "MO" << "MS" << "MT" << "NC" << "ND" << "NE" + << "NFL" << "NH" << "NL" << "NLI" << "NM" << "NNJ" + << "NNY" << "NT" << "NTX" << "NV" << "OH" << "OK" + << "ONE" << "ONN" << "ONS" << "OR" << "ORG" << "PAC" + << "PR" << "QC" << "RI" << "SB" << "SC" << "SCV" + << "SD" << "SDG" << "SF" << "SFL" << "SJV" << "SK" + << "SNJ" << "STX" << "SV" << "TN" << "UT" << "VA" + << "VI" << "VT" << "WCF" << "WI" << "WMA" << "WNY" + << "WPA" << "WTX" << "WV" << "WWA" << "WY" << "DX"; + if(sections.contains(w.at(1))) ok=true; + } + +done: + qDebug() << input << ok; + if(ok) return Acceptable; +// return Invalid; + return Acceptable; +} diff --git a/ExchangeValidator.hpp b/ExchangeValidator.hpp new file mode 100644 index 000000000..1e7b508dc --- /dev/null +++ b/ExchangeValidator.hpp @@ -0,0 +1,19 @@ +#ifndef EXCHANGE_VALIDATOR_HPP__ +#define EXCHANGE_VALIDATOR_HPP__ + +#include + +// ExchangeValidator - QValidator for Field Day and RTTY Roundup exchanges + +class ExchangeValidator final + : public QValidator +{ +public: + ExchangeValidator (QObject * parent = nullptr); + + // QValidator implementation + State validate (QString& input, int& length) const override; + +}; + +#endif diff --git a/lib/77bit/exch_valid.f90 b/lib/77bit/exch_valid.f90 deleted file mode 100644 index 70613fc9a..000000000 --- a/lib/77bit/exch_valid.f90 +++ /dev/null @@ -1,61 +0,0 @@ -logical*1 function exch_valid(ntype,exch) - - parameter (NSEC=84) !Number of ARRL Sections - parameter (NUSCAN=65) !Number of US states and Canadian provinces - - character*(*) exch - character*3 c3 - character*3 cmult(NUSCAN) - character*3 csec(NSEC) - - data csec/ & - "AB ","AK ","AL ","AR ","AZ ","BC ","CO ","CT ","DE ","EB ", & - "EMA","ENY","EPA","EWA","GA ","GTA","IA ","ID ","IL ","IN ", & - "KS ","KY ","LA ","LAX","MAR","MB ","MDC","ME ","MI ","MN ", & - "MO ","MS ","MT ","NC ","ND ","NE ","NFL","NH ","NL ","NLI", & - "NM ","NNJ","NNY","NT ","NTX","NV ","OH ","OK ","ONE","ONN", & - "ONS","OR ","ORG","PAC","PR ","QC ","RI ","SB ","SC ","SCV", & - "SD ","SDG","SF ","SFL","SJV","SK ","SNJ","STX","SV ","TN ", & - "UT ","VA ","VI ","VT ","WCF","WI ","WMA","WNY","WPA","WTX", & - "WV ","WWA","WY ","DX "/ - data cmult/ & - "AL ","AK ","AZ ","AR ","CA ","CO ","CT ","DE ","FL ","GA ", & - "HI ","ID ","IL ","IN ","IA ","KS ","KY ","LA ","ME ","MD ", & - "MA ","MI ","MN ","MS ","MO ","MT ","NE ","NV ","NH ","NJ ", & - "NM ","NY ","NC ","ND ","OH ","OK ","OR ","PA ","RI ","SC ", & - "SD ","TN ","TX ","UT ","VT ","VA ","WA ","WV ","WI ","WY ", & - "NB ","NS ","QC ","ON ","MB ","SK ","AB ","BC ","NWT","NF ", & - "LB ","NU ","YT ","PEI","DC "/ - - exch_valid=.false. - n=len(trim(exch)) - if(ntype.ne.3 .and. ntype.ne.4) go to 900 - if(ntype.eq.3 .and. (n.lt.2 .or. n.gt.7)) go to 900 - if(ntype.eq.4 .and. (n.lt.2 .or. n.gt.3)) go to 900 - - if(ntype.eq.3) then !Field Day - i1=index(exch,' ') - if(i1.lt.3) go to 900 - read(exch(1:i1-2),*,err=900) ntx - if(ntx.lt.1 .or. ntx.gt.32) go to 900 - if(exch(i1-1:i1-1).lt.'A' .or. exch(i1-1:i1-1).gt.'F') go to 900 - c3=exch(i1+1:)//' ' - do i=1,NSEC - if(csec(i).eq.c3) then - exch_valid=.true. - go to 900 - endif - enddo - - else if(ntype.eq.4) then !RTTY Roundup - c3=exch//' ' - do i=1,NUSCAN - if(cmult(i).eq.c3) then - exch_valid=.true. - go to 900 - endif - enddo - endif - -900 return -end function exch_valid diff --git a/mainwindow.cpp b/mainwindow.cpp index 713ea4c13..b13b5b290 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -58,6 +58,7 @@ #include "MultiSettings.hpp" #include "MaidenheadLocatorValidator.hpp" #include "CallsignValidator.hpp" +#include "ExchangeValidator.hpp" #include "EqualizationToolsDialog.hpp" #include "ui_mainwindow.h" diff --git a/wsjtx.pro b/wsjtx.pro index 3d16edf02..5c2124af0 100644 --- a/wsjtx.pro +++ b/wsjtx.pro @@ -67,7 +67,8 @@ SOURCES += \ echoplot.cpp echograph.cpp fastgraph.cpp fastplot.cpp Modes.cpp \ WSPRBandHopping.cpp MessageAggregator.cpp SampleDownloader.cpp qt_helpers.cpp\ MultiSettings.cpp PhaseEqualizationDialog.cpp IARURegions.cpp MessageBox.cpp \ - EqualizationToolsDialog.cpp CallsignValidator.cpp colorhighlighting.cpp + EqualizationToolsDialog.cpp CallsignValidator.cpp ExchangeValidator.cpp \ + colorhighlighting.cpp HEADERS += qt_helpers.hpp \ pimpl_h.hpp pimpl_impl.hpp \ @@ -83,7 +84,8 @@ HEADERS += qt_helpers.hpp \ logbook/logbook.h logbook/countrydat.h logbook/countriesworked.h logbook/adif.h \ messageaveraging.h echoplot.h echograph.h fastgraph.h fastplot.h Modes.hpp WSPRBandHopping.hpp \ WsprTxScheduler.h SampleDownloader.hpp MultiSettings.hpp PhaseEqualizationDialog.hpp \ - IARURegions.hpp MessageBox.hpp EqualizationToolsDialog.hpp CallsignValidator.hpp colorhighlighting.h + IARURegions.hpp MessageBox.hpp EqualizationToolsDialog.hpp CallsignValidator.hpp \ + ExchangeValidator.hpp colorhighlighting.h INCLUDEPATH += qmake_only From 0c9e9aeadc233da756d0f96e60366f2935c92ca7 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Tue, 2 Oct 2018 10:03:11 -0400 Subject: [PATCH 4/4] Implement a QValidator for the Field Day and RTTY exchanges. --- Configuration.cpp | 28 ++++++++++++++++++++++++++++ Configuration.ui | 10 +++++----- ExchangeValidator.cpp | 4 +--- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/Configuration.cpp b/Configuration.cpp index 26425fca0..719fe731d 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -457,6 +457,10 @@ private: Q_SLOT void on_cbx2ToneSpacing_clicked(bool); Q_SLOT void on_cbx4ToneSpacing_clicked(bool); Q_SLOT void on_rbNone_toggled(bool); + Q_SLOT void on_rbFieldDay_toggled(); + Q_SLOT void on_rbRTTYroundup_toggled(); + Q_SLOT void on_FieldDay_Exchange_textChanged(); + Q_SLOT void on_RTTY_Exchange_textChanged(); // typenames used as arguments must match registered type names :( Q_SIGNAL void start_transceiver (unsigned seqeunce_number) const; @@ -2348,6 +2352,20 @@ void Configuration::impl::on_add_macro_line_edit_editingFinished () ui_->add_macro_line_edit->setText (ui_->add_macro_line_edit->text ().toUpper ()); } +void Configuration::impl::on_FieldDay_Exchange_textChanged() +{ + bool b=ui_->FieldDay_Exchange->hasAcceptableInput() or !ui_->rbFieldDay->isChecked(); + if(b) ui_->FieldDay_Exchange->setStyleSheet("color: black"); + if(!b) ui_->FieldDay_Exchange->setStyleSheet("color: red"); +} + +void Configuration::impl::on_RTTY_Exchange_textChanged() +{ + bool b=ui_->RTTY_Exchange->hasAcceptableInput() or !ui_->rbRTTYroundup->isChecked(); + if(b) ui_->RTTY_Exchange->setStyleSheet("color: black"); + if(!b) ui_->RTTY_Exchange->setStyleSheet("color: red"); +} + void Configuration::impl::on_delete_macro_push_button_clicked (bool /* checked */) { auto selection_model = ui_->macros_list_view->selectionModel (); @@ -2612,6 +2630,16 @@ void Configuration::impl::on_rbNone_toggled(bool b) if(!b) ui_->cbGenerate77->setChecked(true); } +void Configuration::impl::on_rbFieldDay_toggled() +{ + on_FieldDay_Exchange_textChanged(); +} + +void Configuration::impl::on_rbRTTYroundup_toggled() +{ + on_RTTY_Exchange_textChanged(); +} + void Configuration::impl::on_cbx2ToneSpacing_clicked(bool b) { if(b) ui_->cbx4ToneSpacing->setChecked(false); diff --git a/Configuration.ui b/Configuration.ui index 34366a1a0..47cd2147c 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -2805,7 +2805,7 @@ Right click for insert and delete options. - + Exch: @@ -2859,7 +2859,7 @@ Right click for insert and delete options. - + Exch: @@ -3106,12 +3106,12 @@ soundcard changes - + - - + + diff --git a/ExchangeValidator.cpp b/ExchangeValidator.cpp index e825d00ca..92c77e6aa 100644 --- a/ExchangeValidator.cpp +++ b/ExchangeValidator.cpp @@ -60,8 +60,6 @@ auto ExchangeValidator::validate (QString& input, int& length) const -> State } done: - qDebug() << input << ok; if(ok) return Acceptable; -// return Invalid; - return Acceptable; + return Intermediate; }