diff --git a/ChangeLog b/ChangeLog index 66916155..b9cabe3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24459,3 +24459,6 @@ 2023-11-06 Fred Gleason * Fixed a bug in rdlogmanager(1) that caused scheduler codes containing space characters to fail to be processed correctly. +2023-11-06 Fred Gleason + * Added checks to the 'Add Scheduler Code' dialog in rdadmin(1) to + enforce the use of only alphanumeric characters plus space. diff --git a/rdadmin/add_schedcodes.cpp b/rdadmin/add_schedcodes.cpp index 7f0cf402..d98319b7 100644 --- a/rdadmin/add_schedcodes.cpp +++ b/rdadmin/add_schedcodes.cpp @@ -3,7 +3,7 @@ // Add scheduler codes dialog // // (C) Copyright 2005-2018 Stefan Gabriel -// (C) Copyright 2018-2021 Fred Gleason +// (C) Copyright 2018-2023 Fred Gleason // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -43,32 +44,33 @@ AddSchedCode::AddSchedCode(QWidget *parent) // Code Name // d_code_edit=new QLineEdit(this); - d_code_edit->setGeometry(105,11,sizeHint().width()-150,19); d_code_edit->setMaxLength(10); - QLabel *label=new QLabel(tr("New Code:"),this); - label->setGeometry(10,11,90,19); - label->setFont(labelFont()); - label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); + QRegExpValidator *code_validator= + new QRegExpValidator(QRegExp("[a-z0-9 ]{1,10}",Qt::CaseInsensitive),this); + d_code_edit->setValidator(code_validator); + connect(d_code_edit,SIGNAL(textChanged(const QString &)), + this,SLOT(codeChangedData(const QString &))); + d_code_label=new QLabel(tr("New Code:"),this); + d_code_label->setFont(labelFont()); + d_code_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); // // Ok Button // - QPushButton *ok_button=new QPushButton(this); - ok_button->setGeometry(sizeHint().width()-180,sizeHint().height()-60,80,50); - ok_button->setDefault(true); - ok_button->setFont(buttonFont()); - ok_button->setText(tr("OK")); - connect(ok_button,SIGNAL(clicked()),this,SLOT(okData())); + d_ok_button=new QPushButton(this); + d_ok_button->setDefault(true); + d_ok_button->setFont(buttonFont()); + d_ok_button->setText(tr("OK")); + d_ok_button->setDisabled(true); + connect(d_ok_button,SIGNAL(clicked()),this,SLOT(okData())); // // Cancel Button // - QPushButton *cancel_button=new QPushButton(this); - cancel_button-> - setGeometry(sizeHint().width()-90,sizeHint().height()-60,80,50); - cancel_button->setFont(buttonFont()); - cancel_button->setText(tr("Cancel")); - connect(cancel_button,SIGNAL(clicked()),this,SLOT(cancelData())); + d_cancel_button=new QPushButton(this); + d_cancel_button->setFont(buttonFont()); + d_cancel_button->setText(tr("Cancel")); + connect(d_cancel_button,SIGNAL(clicked()),this,SLOT(cancelData())); } @@ -100,6 +102,22 @@ int AddSchedCode::exec(QString *scode) } +void AddSchedCode::resizeEvent(QResizeEvent *e) +{ + d_code_label->setGeometry(10,11,90,19); + d_code_edit->setGeometry(105,11,size().width()-150,19); + + d_ok_button->setGeometry(size().width()-180,sizeHint().height()-60,80,50); + d_cancel_button->setGeometry(size().width()-90,size().height()-60,80,50); +} + + +void AddSchedCode::codeChangedData(const QString &str) +{ + d_ok_button->setDisabled(str.isEmpty()); +} + + void AddSchedCode::okData() { if(d_code_edit->text().isEmpty()) { diff --git a/rdadmin/add_schedcodes.h b/rdadmin/add_schedcodes.h index 99e608ac..633d99f5 100644 --- a/rdadmin/add_schedcodes.h +++ b/rdadmin/add_schedcodes.h @@ -3,7 +3,7 @@ // Add scheduler codes dialog // // (C) Copyright Stefan Gabriel -// (C) Copyright 2002-2021 Fred Gleason +// (C) Copyright 2002-2023 Fred Gleason // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as @@ -22,6 +22,8 @@ #ifndef ADD_SCHEDCODES_H #define ADD_SCHEDCODES_H +#include +#include #include #include @@ -38,12 +40,19 @@ class AddSchedCode : public RDDialog public slots: int exec(QString *scode); + protected: + void resizeEvent(QResizeEvent *e); + private slots: + void codeChangedData(const QString &str); void okData(); void cancelData(); private: + QLabel *d_code_label; QLineEdit *d_code_edit; + QPushButton *d_ok_button; + QPushButton *d_cancel_button; QString *d_sched_code; };