diff --git a/CMakeLists.txt b/CMakeLists.txt index 83100946f..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 diff --git a/Configuration.cpp b/Configuration.cpp index ba9b74bcd..719fe731d 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" @@ -456,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; @@ -997,12 +1002,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<port_type>::max ()); @@ -2347,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 (); @@ -2611,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.</string> <item> <layout class="QFormLayout" name="formLayout_17"> <item row="0" column="0"> - <widget class="QLabel" name="label_15"> + <widget class="QLabel" name="labRTTY"> <property name="text"> <string>Exch:</string> </property> @@ -2859,7 +2859,7 @@ Right click for insert and delete options.</string> <item> <layout class="QFormLayout" name="formLayout_16"> <item row="0" column="0"> - <widget class="QLabel" name="label_14"> + <widget class="QLabel" name="labFD"> <property name="text"> <string>Exch:</string> </property> @@ -3106,12 +3106,12 @@ soundcard changes</string> </connection> </connections> <buttongroups> - <buttongroup name="CAT_stop_bits_button_group"/> <buttongroup name="CAT_data_bits_button_group"/> <buttongroup name="CAT_handshake_button_group"/> + <buttongroup name="CAT_stop_bits_button_group"/> <buttongroup name="TX_mode_button_group"/> - <buttongroup name="PTT_method_button_group"/> - <buttongroup name="TX_audio_source_button_group"/> <buttongroup name="split_mode_button_group"/> + <buttongroup name="TX_audio_source_button_group"/> + <buttongroup name="PTT_method_button_group"/> </buttongroups> </ui> diff --git a/ExchangeValidator.cpp b/ExchangeValidator.cpp new file mode 100644 index 000000000..92c77e6aa --- /dev/null +++ b/ExchangeValidator.cpp @@ -0,0 +1,65 @@ +#include <QDebug> +#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<char *>(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: + if(ok) return Acceptable; + return Intermediate; +} 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 <QValidator> + +// 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/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/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 353bd4aea..5c2124af0 100644 --- a/wsjtx.pro +++ b/wsjtx.pro @@ -67,8 +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 \ - colorhighlighting.cpp + EqualizationToolsDialog.cpp CallsignValidator.cpp ExchangeValidator.cpp \ + colorhighlighting.cpp HEADERS += qt_helpers.hpp \ pimpl_h.hpp pimpl_impl.hpp \ @@ -84,8 +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 \ - colorhighlighting.h + IARURegions.hpp MessageBox.hpp EqualizationToolsDialog.hpp CallsignValidator.hpp \ + ExchangeValidator.hpp colorhighlighting.h INCLUDEPATH += qmake_only