fix(cpn): radio specific name and label validators (#4670)
Only allows valid characters in names, drops invalid characters if present
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "helpers.h"
|
||||
#include "filtereditemmodels.h"
|
||||
#include "curveimagewidget.h"
|
||||
#include "namevalidator.h"
|
||||
|
||||
LimitsGroup::LimitsGroup(Firmware * firmware, TableLayout * tableLayout, int row, int col, int & value, const ModelData & model, GeneralSettings & generalSettings,
|
||||
int min, int max, int deflt, FilteredItemModel * gvarModel, ModelPanel * panel):
|
||||
@@ -91,6 +92,8 @@ ChannelsPanel::ChannelsPanel(QWidget * parent, ModelData & model, GeneralSetting
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
sharedItemModels(sharedItemModels)
|
||||
{
|
||||
Board::Type board = firmware->getBoard();
|
||||
|
||||
chnCapability = firmware->getCapability(Outputs);
|
||||
int channelNameMaxLen = firmware->getCapability(ChannelsName);
|
||||
|
||||
@@ -107,7 +110,7 @@ ChannelsPanel::ChannelsPanel(QWidget * parent, ModelData & model, GeneralSetting
|
||||
headerLabels << tr("Name");
|
||||
}
|
||||
headerLabels << tr("Subtrim") << tr("Min") << tr("Max") << tr("Direction");
|
||||
if (IS_HORUS_OR_TARANIS(firmware->getBoard()))
|
||||
if (IS_HORUS_OR_TARANIS(board))
|
||||
headerLabels << tr("Curve") << tr("Plot");
|
||||
if (firmware->getCapability(PPMCenter))
|
||||
headerLabels << tr("PPM Center");
|
||||
@@ -134,8 +137,7 @@ ChannelsPanel::ChannelsPanel(QWidget * parent, ModelData & model, GeneralSetting
|
||||
name[i] = new QLineEdit(this);
|
||||
name[i]->setProperty("index", i);
|
||||
name[i]->setMaxLength(channelNameMaxLen);
|
||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||
name[i]->setValidator(new QRegExpValidator(rx, this));
|
||||
name[i]->setValidator(new NameValidator(board, this));
|
||||
connect(name[i], SIGNAL(editingFinished()), this, SLOT(nameEdited()));
|
||||
tableLayout->addWidget(i, col++, name[i]);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ui_expodialog.h"
|
||||
#include "filtereditemmodels.h"
|
||||
#include "helpers.h"
|
||||
#include "namevalidator.h"
|
||||
|
||||
ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, GeneralSettings & generalSettings,
|
||||
Firmware * firmware, QString & inputName, CompoundItemModelFactory * sharedItemModels) :
|
||||
@@ -37,6 +38,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
Board::Type board = firmware->getBoard();
|
||||
dialogFilteredItemModels = new FilteredItemModelFactory();
|
||||
int id;
|
||||
|
||||
@@ -48,7 +50,6 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
||||
|
||||
RawSourceType srcType = (firmware->getCapability(VirtualInputs) ? SOURCE_TYPE_VIRTUAL_INPUT : SOURCE_TYPE_STICK);
|
||||
setWindowTitle(tr("Edit %1").arg(RawSource(srcType, ed->chn).toString(&model, &generalSettings)));
|
||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||
|
||||
id = dialogFilteredItemModels->registerItemModel(new FilteredItemModel(sharedItemModels->getItemModel(AbstractItemModel::IMID_GVarRef)), "GVarRef");
|
||||
gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, ed->weight, model, 100, -100, 100, 1.0,
|
||||
@@ -108,7 +109,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
||||
flags), "RawSource");
|
||||
ui->sourceCB->setModel(dialogFilteredItemModels->getItemModel(id));
|
||||
ui->sourceCB->setCurrentIndex(ui->sourceCB->findData(ed->srcRaw.toValue()));
|
||||
ui->inputName->setValidator(new QRegExpValidator(rx, this));
|
||||
ui->inputName->setValidator(new NameValidator(board, this));
|
||||
ui->inputName->setText(inputName);
|
||||
}
|
||||
else {
|
||||
@@ -140,7 +141,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
||||
ui->lineName->setMaxLength(expolength);
|
||||
}
|
||||
|
||||
ui->lineName->setValidator(new QRegExpValidator(rx, this));
|
||||
ui->lineName->setValidator(new NameValidator(board, this));
|
||||
ui->lineName->setText(ed->name);
|
||||
|
||||
updateScale();
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "filtereditemmodels.h"
|
||||
#include "helpers.h"
|
||||
#include "customdebug.h"
|
||||
#include "namevalidator.h"
|
||||
|
||||
FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseIdx, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
FilteredItemModel * rawSwitchFilteredModel):
|
||||
@@ -45,9 +46,8 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
|
||||
trimCount = Boards::getCapability(board, Board::NumTrims);
|
||||
|
||||
// Flight mode name
|
||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||
if (fmCount) {
|
||||
ui->name->setValidator(new QRegExpValidator(rx, this));
|
||||
ui->name->setValidator(new NameValidator(board, this));
|
||||
ui->name->setMaxLength(firmware->getCapability(FlightModesName));
|
||||
connect(ui->name, SIGNAL(editingFinished()), this, SLOT(phaseName_editingFinished()));
|
||||
}
|
||||
@@ -231,6 +231,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
|
||||
if (nameLen > 0) {
|
||||
gvNames[i] = new QLineEdit(ui->gvGB);
|
||||
gvNames[i]->setProperty("index", i);
|
||||
gvNames[i]->setValidator(new NameValidator(board, this));
|
||||
gvNames[i]->setMaxLength(nameLen);
|
||||
connect(gvNames[i], SIGNAL(editingFinished()), this, SLOT(GVName_editingFinished()));
|
||||
gvLayout->addWidget(gvNames[i], i + 1, col++, 1, 1);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "radiodata.h"
|
||||
#include "filtereditemmodels.h"
|
||||
#include "helpers.h"
|
||||
#include "namevalidator.h"
|
||||
|
||||
MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
CompoundItemModelFactory * sharedItemModels) :
|
||||
@@ -41,7 +42,6 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata,
|
||||
dialogFilteredItemModels = new FilteredItemModelFactory();
|
||||
int id;
|
||||
|
||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||
QLabel * lb_fp[CPN_MAX_FLIGHT_MODES] = {ui->lb_FP0, ui->lb_FP1, ui->lb_FP2, ui->lb_FP3, ui->lb_FP4, ui->lb_FP5, ui->lb_FP6, ui->lb_FP7, ui->lb_FP8 };
|
||||
QCheckBox * tmp[CPN_MAX_FLIGHT_MODES] = {ui->cb_FP0, ui->cb_FP1, ui->cb_FP2, ui->cb_FP3, ui->cb_FP4, ui->cb_FP5, ui->cb_FP6, ui->cb_FP7, ui->cb_FP8 };
|
||||
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
|
||||
@@ -100,7 +100,7 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata,
|
||||
else {
|
||||
ui->mixerName->setMaxLength(namelength);
|
||||
}
|
||||
ui->mixerName->setValidator(new QRegExpValidator(rx, this));
|
||||
ui->mixerName->setValidator(new NameValidator(board, this));
|
||||
ui->mixerName->setText(md->name);
|
||||
|
||||
if (!firmware->getCapability(FlightModes)) {
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "checklistdialog.h"
|
||||
#include "helpers.h"
|
||||
#include "moduledata.h"
|
||||
#include "namevalidator.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
@@ -55,6 +56,7 @@ TimerPanel::TimerPanel(QWidget * parent, ModelData & model, TimerData & timer, G
|
||||
if (length == 0)
|
||||
ui->name->hide();
|
||||
else {
|
||||
ui->name->setValidator(new NameValidator(firmware->getBoard(), this));
|
||||
ui->name->setField(timer.name, length, this);
|
||||
connect(ui->name, SIGNAL(currentDataChanged()), this, SLOT(onNameChanged()));
|
||||
}
|
||||
@@ -1253,11 +1255,11 @@ FunctionSwitchesPanel::FunctionSwitchesPanel(QWidget * parent, ModelData & model
|
||||
AbstractStaticItemModel *fsConfig = ModelData::funcSwitchConfigItemModel();
|
||||
AbstractStaticItemModel *fsStart = ModelData::funcSwitchStartItemModel();
|
||||
|
||||
Board::Type board = firmware->getBoard();
|
||||
|
||||
lock = true;
|
||||
|
||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||
|
||||
switchcnt = Boards::getCapability(firmware->getBoard(), Board::FunctionSwitches);
|
||||
switchcnt = Boards::getCapability(board, Board::FunctionSwitches);
|
||||
|
||||
for (int i = 0; i < switchcnt; i++) {
|
||||
QLabel * lblSwitchId = new QLabel(this);
|
||||
@@ -1265,7 +1267,7 @@ FunctionSwitchesPanel::FunctionSwitchesPanel(QWidget * parent, ModelData & model
|
||||
|
||||
AutoLineEdit * aleName = new AutoLineEdit(this);
|
||||
aleName->setProperty("index", i);
|
||||
aleName->setValidator(new QRegExpValidator(rx, this));
|
||||
aleName->setValidator(new NameValidator(board, this));
|
||||
aleName->setField((char *)model.functionSwitchNames[i], 3);
|
||||
|
||||
QComboBox * cboConfig = new QComboBox(this);
|
||||
@@ -1481,8 +1483,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
|
||||
memset(modules, 0, sizeof(modules));
|
||||
|
||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||
ui->name->setValidator(new QRegExpValidator(rx, this));
|
||||
ui->name->setValidator(new NameValidator(board, this));
|
||||
ui->name->setMaxLength(firmware->getCapability(ModelName));
|
||||
|
||||
if (firmware->getCapability(HasModelImage)) {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "ui_telemetry_sensor.h"
|
||||
#include "helpers.h"
|
||||
#include "appdata.h"
|
||||
#include "namevalidator.h"
|
||||
|
||||
constexpr char FIM_RAWSOURCE[] {"Raw Source"};
|
||||
constexpr char FIM_TELEALLSRC[] {"Tele All Source"};
|
||||
@@ -64,6 +65,7 @@ TelemetrySensorPanel::TelemetrySensorPanel(QWidget *parent, SensorData & sensor,
|
||||
ui->numLabel->setToolTip(tr("Popup menu available"));
|
||||
ui->numLabel->setMouseTracking(true);
|
||||
connect(ui->numLabel, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(on_customContextMenuRequested(QPoint)));
|
||||
ui->name->setValidator(new NameValidator(firmware->getBoard(), this));
|
||||
ui->name->setField(sensor.label, SENSOR_LABEL_LEN);
|
||||
connect(ui->name, SIGNAL(currentDataChanged()), this, SLOT(on_nameDataChanged()));
|
||||
ui->id->setField(sensor.id, this);
|
||||
|
||||
Reference in New Issue
Block a user