mirror of https://github.com/saitohirga/WSJT-X.git
Add validation to message entry fields.
All message entry fields on the mainscreen and in the macro editing facilities are now restricted to valid characters in the JT65/JT9 free text message alphabet. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4362 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
960601b8fe
commit
248f78d780
|
@ -60,6 +60,8 @@ namespace
|
||||||
// disabled
|
// disabled
|
||||||
int const combo_box_item_enabled (32 | 1);
|
int const combo_box_item_enabled (32 | 1);
|
||||||
int const combo_box_item_disabled (0);
|
int const combo_box_item_disabled (0);
|
||||||
|
|
||||||
|
QRegExp message_alphabet {"[- A-Za-z0-9+./?]*"};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,6 +167,32 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Class MessageItemDelegate
|
||||||
|
//
|
||||||
|
// Item delegate for message entry such as free text message macros.
|
||||||
|
//
|
||||||
|
class MessageItemDelegate final
|
||||||
|
: public QStyledItemDelegate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit MessageItemDelegate (QObject * parent = nullptr)
|
||||||
|
: QStyledItemDelegate {parent}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget * createEditor (QWidget * parent
|
||||||
|
, QStyleOptionViewItem const& /* option*/
|
||||||
|
, QModelIndex const& /* index */
|
||||||
|
) const override
|
||||||
|
{
|
||||||
|
auto editor = new QLineEdit {parent};
|
||||||
|
editor->setFrame (false);
|
||||||
|
editor->setValidator (new QRegExpValidator {message_alphabet, editor});
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Fields that are transceiver related.
|
// Fields that are transceiver related.
|
||||||
//
|
//
|
||||||
// These are aggregated in a structure to enable a non-equivalence to
|
// These are aggregated in a structure to enable a non-equivalence to
|
||||||
|
@ -682,7 +710,7 @@ Configuration::impl::impl (Configuration * self, QString const& instance_key, QS
|
||||||
//
|
//
|
||||||
ui_->callsign_line_edit->setValidator (new QRegExpValidator {QRegExp {"[A-Za-z0-9/]+"}, this});
|
ui_->callsign_line_edit->setValidator (new QRegExpValidator {QRegExp {"[A-Za-z0-9/]+"}, this});
|
||||||
ui_->grid_line_edit->setValidator (new QRegExpValidator {QRegExp {"[A-Ra-r]{2,2}[0-9]{2,2}[A-Xa-x]{0,2}"}, this});
|
ui_->grid_line_edit->setValidator (new QRegExpValidator {QRegExp {"[A-Ra-r]{2,2}[0-9]{2,2}[A-Xa-x]{0,2}"}, this});
|
||||||
ui_->add_macro_line_edit->setValidator (new QRegExpValidator {QRegExp {"[ A-Za-z0-9/?]+"}, this});
|
ui_->add_macro_line_edit->setValidator (new QRegExpValidator {message_alphabet, this});
|
||||||
|
|
||||||
//
|
//
|
||||||
// assign ids to radio buttons
|
// assign ids to radio buttons
|
||||||
|
@ -736,6 +764,7 @@ Configuration::impl::impl (Configuration * self, QString const& instance_key, QS
|
||||||
// setup macros list view
|
// setup macros list view
|
||||||
//
|
//
|
||||||
ui_->macros_list_view->setModel (&next_macros_);
|
ui_->macros_list_view->setModel (&next_macros_);
|
||||||
|
ui_->macros_list_view->setItemDelegate (new MessageItemDelegate {this});
|
||||||
|
|
||||||
macro_delete_action_ = new QAction {tr ("&Delete"), ui_->macros_list_view};
|
macro_delete_action_ = new QAction {tr ("&Delete"), ui_->macros_list_view};
|
||||||
ui_->macros_list_view->insertAction (nullptr, macro_delete_action_);
|
ui_->macros_list_view->insertAction (nullptr, macro_delete_action_);
|
||||||
|
|
|
@ -3,9 +3,6 @@
|
||||||
|
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
|
|
||||||
class QStyleOptionItemView;
|
|
||||||
class QWidget;
|
|
||||||
class QModelIndex;
|
|
||||||
class Bands;
|
class Bands;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QRegularExpression>
|
#include <QRegExpValidator>
|
||||||
|
#include <QRegExp>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QtConcurrent/QtConcurrentRun>
|
#include <QtConcurrent/QtConcurrentRun>
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ wchar_t buffer[256];
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
Radio::Frequency constexpr default_frequency {14076000};
|
Radio::Frequency constexpr default_frequency {14076000};
|
||||||
|
QRegExp message_alphabet {"[- A-Za-z0-9+./?]*"};
|
||||||
}
|
}
|
||||||
|
|
||||||
class BandAndFrequencyItemDelegate final
|
class BandAndFrequencyItemDelegate final
|
||||||
|
@ -239,6 +241,15 @@ MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdme
|
||||||
connect (&m_config, &Configuration::transceiver_update, this, &MainWindow::handle_transceiver_update);
|
connect (&m_config, &Configuration::transceiver_update, this, &MainWindow::handle_transceiver_update);
|
||||||
connect (&m_config, &Configuration::transceiver_failure, this, &MainWindow::handle_transceiver_failure);
|
connect (&m_config, &Configuration::transceiver_failure, this, &MainWindow::handle_transceiver_failure);
|
||||||
|
|
||||||
|
// set up message text validators
|
||||||
|
ui->tx1->setValidator (new QRegExpValidator {message_alphabet, this});
|
||||||
|
ui->tx2->setValidator (new QRegExpValidator {message_alphabet, this});
|
||||||
|
ui->tx3->setValidator (new QRegExpValidator {message_alphabet, this});
|
||||||
|
ui->tx4->setValidator (new QRegExpValidator {message_alphabet, this});
|
||||||
|
ui->tx5->setValidator (new QRegExpValidator {message_alphabet, this});
|
||||||
|
ui->tx6->setValidator (new QRegExpValidator {message_alphabet, this});
|
||||||
|
ui->freeTextMsg->setValidator (new QRegExpValidator {message_alphabet, this});
|
||||||
|
|
||||||
// Free text macros model to widget hook up.
|
// Free text macros model to widget hook up.
|
||||||
ui->tx5->setModel (m_config.macros ());
|
ui->tx5->setModel (m_config.macros ());
|
||||||
connect (ui->tx5->lineEdit ()
|
connect (ui->tx5->lineEdit ()
|
||||||
|
|
Loading…
Reference in New Issue