mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-10 17:37:47 +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>
|
2021-08-11 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Adjusted layout in 'RDLogEventDialog' to be compatible with
|
* Adjusted layout in 'RDLogEventDialog' to be compatible with
|
||||||
12 hour time format.
|
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_hours=true;
|
||||||
d_show_tenths=false;
|
d_show_tenths=false;
|
||||||
d_current_step_size=1;
|
|
||||||
d_step_enabled=StepDownEnabled|StepUpEnabled;
|
d_step_enabled=StepDownEnabled|StepUpEnabled;
|
||||||
|
d_width_variance=0;
|
||||||
|
|
||||||
SetFormat();
|
SetFormat();
|
||||||
}
|
}
|
||||||
@ -74,7 +74,8 @@ QValidator::State RDTimeEdit::validate(QString &input,int &pos) const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if(ret==QValidator::Acceptable) {
|
if(ret==QValidator::Acceptable) {
|
||||||
if(input.length()!=displayFormat().length()) {
|
if((input.length()!=displayFormat().length())&&
|
||||||
|
(input.length()!=(displayFormat().length()+d_width_variance))) {
|
||||||
return QValidator::Intermediate;
|
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)
|
void RDTimeEdit::stepBy(int steps)
|
||||||
{
|
{
|
||||||
int step_size=1;
|
int step_size=1;
|
||||||
@ -170,17 +189,21 @@ void RDTimeEdit::SetFormat()
|
|||||||
if(d_show_tenths) {
|
if(d_show_tenths) {
|
||||||
if(d_show_hours) {
|
if(d_show_hours) {
|
||||||
setDisplayFormat(RD_TWELVE_HOUR_TENTHS_FORMAT);
|
setDisplayFormat(RD_TWELVE_HOUR_TENTHS_FORMAT);
|
||||||
|
d_width_variance=1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setDisplayFormat(RD_OFFSET_TENTHS_FORMAT);
|
setDisplayFormat(RD_OFFSET_TENTHS_FORMAT);
|
||||||
|
d_width_variance=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(d_show_hours) {
|
if(d_show_hours) {
|
||||||
setDisplayFormat(RD_TWELVE_HOUR_FORMAT);
|
setDisplayFormat(RD_TWELVE_HOUR_FORMAT);
|
||||||
|
d_width_variance=0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setDisplayFormat(RD_OFFSET_FORMAT);
|
setDisplayFormat(RD_OFFSET_FORMAT);
|
||||||
|
d_width_variance=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,17 +211,21 @@ void RDTimeEdit::SetFormat()
|
|||||||
if(d_show_tenths) {
|
if(d_show_tenths) {
|
||||||
if(d_show_hours) {
|
if(d_show_hours) {
|
||||||
setDisplayFormat(RD_TWENTYFOUR_HOUR_TENTHS_FORMAT);
|
setDisplayFormat(RD_TWENTYFOUR_HOUR_TENTHS_FORMAT);
|
||||||
|
d_width_variance=0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setDisplayFormat(RD_OFFSET_TENTHS_FORMAT);
|
setDisplayFormat(RD_OFFSET_TENTHS_FORMAT);
|
||||||
|
d_width_variance=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(d_show_hours) {
|
if(d_show_hours) {
|
||||||
setDisplayFormat(RD_TWENTYFOUR_HOUR_FORMAT);
|
setDisplayFormat(RD_TWENTYFOUR_HOUR_FORMAT);
|
||||||
|
d_width_variance=0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setDisplayFormat(RD_OFFSET_FORMAT);
|
setDisplayFormat(RD_OFFSET_FORMAT);
|
||||||
|
d_width_variance=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ class RDTimeEdit : public QTimeEdit
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
QValidator::State validate(QString &input,int &pos) const;
|
QValidator::State validate(QString &input,int &pos) const;
|
||||||
|
void fixup(QString &input) const;
|
||||||
void stepBy(int steps);
|
void stepBy(int steps);
|
||||||
QAbstractSpinBox::StepEnabled stepEnabled() const;
|
QAbstractSpinBox::StepEnabled stepEnabled() const;
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ class RDTimeEdit : public QTimeEdit
|
|||||||
void SetFormat();
|
void SetFormat();
|
||||||
bool d_show_hours;
|
bool d_show_hours;
|
||||||
bool d_show_tenths;
|
bool d_show_tenths;
|
||||||
int d_current_step_size;
|
int d_width_variance;
|
||||||
QAbstractSpinBox::StepEnabled d_step_enabled;
|
QAbstractSpinBox::StepEnabled d_step_enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user