mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-20 15:02:27 +02:00
2021-08-11 Fred Gleason <fredg@paravelsystems.com>
* Tightened up the validation checking in 'RDTimeEdit'. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
9d6a202450
commit
d6df214412
@ -22206,3 +22206,5 @@
|
||||
2021-08-11 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Adjusted layout in 'RDLogEventDialog' to be compatible with
|
||||
12 hour time format.
|
||||
2021-08-11 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Tightened up the validation checking in 'RDTimeEdit'.
|
||||
|
@ -29,8 +29,8 @@ RDTimeEdit::RDTimeEdit(QWidget *parent)
|
||||
{
|
||||
d_show_hours=true;
|
||||
d_show_tenths=false;
|
||||
d_current_step_size=1;
|
||||
d_step_enabled=StepDownEnabled|StepUpEnabled;
|
||||
d_width_variance=0;
|
||||
|
||||
SetFormat();
|
||||
}
|
||||
@ -74,7 +74,8 @@ QValidator::State RDTimeEdit::validate(QString &input,int &pos) const
|
||||
return ret;
|
||||
}
|
||||
if(ret==QValidator::Acceptable) {
|
||||
if(input.length()!=displayFormat().length()) {
|
||||
if((input.length()!=displayFormat().length())&&
|
||||
(input.length()!=(displayFormat().length()+d_width_variance))) {
|
||||
return QValidator::Intermediate;
|
||||
}
|
||||
}
|
||||
@ -82,6 +83,24 @@ QValidator::State RDTimeEdit::validate(QString &input,int &pos) const
|
||||
}
|
||||
|
||||
|
||||
void RDTimeEdit::fixup(QString &input) const
|
||||
{
|
||||
//
|
||||
// Don't allow higher precision than tenths of a second
|
||||
//
|
||||
if(d_show_tenths) {
|
||||
QStringList f0=input.split(".",QString::KeepEmptyParts);
|
||||
if(f0.size()==2) {
|
||||
QStringList f1=f0.at(1).split(" ");
|
||||
if(f1.at(0).length()>1) {
|
||||
input.replace("."+f1.at(0),"."+f1.at(0).left(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
QTimeEdit::fixup(input);
|
||||
}
|
||||
|
||||
|
||||
void RDTimeEdit::stepBy(int steps)
|
||||
{
|
||||
int step_size=1;
|
||||
@ -170,17 +189,21 @@ void RDTimeEdit::SetFormat()
|
||||
if(d_show_tenths) {
|
||||
if(d_show_hours) {
|
||||
setDisplayFormat(RD_TWELVE_HOUR_TENTHS_FORMAT);
|
||||
d_width_variance=1;
|
||||
}
|
||||
else {
|
||||
setDisplayFormat(RD_OFFSET_TENTHS_FORMAT);
|
||||
d_width_variance=0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(d_show_hours) {
|
||||
setDisplayFormat(RD_TWELVE_HOUR_FORMAT);
|
||||
d_width_variance=0;
|
||||
}
|
||||
else {
|
||||
setDisplayFormat(RD_OFFSET_FORMAT);
|
||||
d_width_variance=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -188,17 +211,21 @@ void RDTimeEdit::SetFormat()
|
||||
if(d_show_tenths) {
|
||||
if(d_show_hours) {
|
||||
setDisplayFormat(RD_TWENTYFOUR_HOUR_TENTHS_FORMAT);
|
||||
d_width_variance=0;
|
||||
}
|
||||
else {
|
||||
setDisplayFormat(RD_OFFSET_TENTHS_FORMAT);
|
||||
d_width_variance=0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(d_show_hours) {
|
||||
setDisplayFormat(RD_TWENTYFOUR_HOUR_FORMAT);
|
||||
d_width_variance=0;
|
||||
}
|
||||
else {
|
||||
setDisplayFormat(RD_OFFSET_FORMAT);
|
||||
d_width_variance=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ class RDTimeEdit : public QTimeEdit
|
||||
|
||||
protected:
|
||||
QValidator::State validate(QString &input,int &pos) const;
|
||||
void fixup(QString &input) const;
|
||||
void stepBy(int steps);
|
||||
QAbstractSpinBox::StepEnabled stepEnabled() const;
|
||||
|
||||
@ -43,7 +44,7 @@ class RDTimeEdit : public QTimeEdit
|
||||
void SetFormat();
|
||||
bool d_show_hours;
|
||||
bool d_show_tenths;
|
||||
int d_current_step_size;
|
||||
int d_width_variance;
|
||||
QAbstractSpinBox::StepEnabled d_step_enabled;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user