Fix: save time value properly
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2454 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
687d0023d0
commit
cf72334b8a
@ -5,6 +5,7 @@ Note: Lazarus Trunk required
|
|||||||
|
|
||||||
Version pre-1.1
|
Version pre-1.1
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
2012-06-12 Fixed: TJDbGridTimeCtrl, store time value
|
||||||
2012-03-14 Fixed: Prevent double updates (QT widgetset) in edit widgets
|
2012-03-14 Fixed: Prevent double updates (QT widgetset) in edit widgets
|
||||||
2012-03-06 Fixed: Focus issues
|
2012-03-06 Fixed: Focus issues
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
aTime := StrToTime(texto);
|
aTime := StrToTime(texto);
|
||||||
Result := TimeString;// FormatDateTime(aTimeFormat, aTime);
|
Result := TimeString;// FormatDateTime(aTimeFormat, aTime);
|
||||||
end;
|
end
|
||||||
end;
|
end;
|
||||||
tokens.Free;
|
tokens.Free;
|
||||||
//ShowMessage('Hora normalizada: ' + Result);
|
//ShowMessage('Hora normalizada: ' + Result);
|
||||||
|
@ -321,7 +321,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
ShowMessage(Format(SInvalidDateTime, [CellEditor.Caption]));
|
ShowMessage(Format(SInvalidDateTime, [CellEditor.Caption]));
|
||||||
if Field.IsNull then
|
if Field.IsNull then
|
||||||
CellEditor.Text:= ''
|
CellEditor.Text := ''
|
||||||
else
|
else
|
||||||
CellEditor.Text := FormatDateTime(DisplayFormat, Field.AsDateTime);
|
CellEditor.Text := FormatDateTime(DisplayFormat, Field.AsDateTime);
|
||||||
end;
|
end;
|
||||||
@ -367,7 +367,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
ShowMessage(Format(SInvalidDateTime, [CellEditor.Caption]));
|
ShowMessage(Format(SInvalidDateTime, [CellEditor.Caption]));
|
||||||
if Field.IsNull then
|
if Field.IsNull then
|
||||||
CellEditor.Text:= ''
|
CellEditor.Text := ''
|
||||||
else
|
else
|
||||||
CellEditor.Text := FormatDateTime(DisplayFormat, theValue);
|
CellEditor.Text := FormatDateTime(DisplayFormat, theValue);
|
||||||
CellEditor.SelectAll;
|
CellEditor.SelectAll;
|
||||||
@ -437,7 +437,7 @@ end;
|
|||||||
function TJDbGridDateTimeCtrl.CanDefocus: boolean;
|
function TJDbGridDateTimeCtrl.CanDefocus: boolean;
|
||||||
begin
|
begin
|
||||||
if not updated then
|
if not updated then
|
||||||
Result:= True
|
Result := True
|
||||||
else
|
else
|
||||||
if CellEditor.Focused and (Length(CellEditor.Text) = 0) then
|
if CellEditor.Focused and (Length(CellEditor.Text) = 0) then
|
||||||
Result := True
|
Result := True
|
||||||
@ -497,7 +497,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
Field.DataSet.DisableControls;
|
Field.DataSet.DisableControls;
|
||||||
Field.DataSet.Edit;
|
Field.DataSet.Edit;
|
||||||
Field.AsDateTime := theValue;
|
Field.Text := NormalizeTime(CellEditor.Caption, Field.AsDateTime);
|
||||||
Field.DataSet.EnableControls;
|
Field.DataSet.EnableControls;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -506,7 +506,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
ShowMessage(Format(SInvalidTime, [CellEditor.Caption]));
|
ShowMessage(Format(SInvalidTime, [CellEditor.Caption]));
|
||||||
if Field.IsNull then
|
if Field.IsNull then
|
||||||
CellEditor.Text:= ''
|
CellEditor.Text := ''
|
||||||
else
|
else
|
||||||
CellEditor.Text := FormatDateTime(DisplayFormat, Field.AsDateTime);
|
CellEditor.Text := FormatDateTime(DisplayFormat, Field.AsDateTime);
|
||||||
end;
|
end;
|
||||||
@ -545,48 +545,49 @@ begin
|
|||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if (Key in [VK_RETURN, VK_TAB, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT]) and
|
if Length(CellEditor.Caption) <> 0 then
|
||||||
(not IsValidTimeString(NormalizeTime(CellEditor.Caption, theValue))) then
|
if (Key in [VK_RETURN, VK_TAB, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT]) and
|
||||||
begin
|
(not IsValidTimeString(NormalizeTime(CellEditor.Caption, theValue))) then
|
||||||
ShowMessage(Format(SInvalidTime, [CellEditor.Caption]));
|
|
||||||
if Field.IsNull then
|
|
||||||
CellEditor.Text:= ''
|
|
||||||
else
|
|
||||||
CellEditor.Text := FormatDateTime(DisplayFormat, theValue);
|
|
||||||
CellEditor.SelectAll;
|
|
||||||
Key := VK_UNKNOWN;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if key = VK_ESCAPE then
|
|
||||||
begin
|
|
||||||
if Field.IsNull then
|
|
||||||
CellEditor.Text := ''
|
|
||||||
else
|
|
||||||
CellEditor.Text := FormatDateTime(DisplayFormat, Field.AsDateTime);
|
|
||||||
updated := True;
|
|
||||||
theGrid.SetFocus; // No perder el foco
|
|
||||||
end
|
|
||||||
else
|
|
||||||
//if Key in [VK_UP, VK_DOWN] then
|
|
||||||
//begin
|
|
||||||
// Key := VK_UNKNOWN;
|
|
||||||
//end
|
|
||||||
//else
|
|
||||||
if Key in [VK_RETURN, VK_TAB, VK_UP, VK_DOWN] then
|
|
||||||
begin
|
|
||||||
CellEditor.Caption := NormalizeTime(CellEditor.Caption, theValue);
|
|
||||||
if Length(CellEditor.Caption) = 0 then
|
|
||||||
theValue := 0
|
|
||||||
else
|
|
||||||
if IsValidTimeString(CellEditor.Caption) then
|
|
||||||
begin
|
begin
|
||||||
theValue := StrToTime(CellEditor.Caption);
|
ShowMessage(Format(SInvalidTime, [CellEditor.Caption]));
|
||||||
Field.DataSet.Edit;
|
if Field.IsNull then
|
||||||
Field.AsDateTime := theValue;
|
CellEditor.Text := ''
|
||||||
|
else
|
||||||
|
CellEditor.Text := FormatDateTime(DisplayFormat, theValue);
|
||||||
CellEditor.SelectAll;
|
CellEditor.SelectAll;
|
||||||
|
Key := VK_UNKNOWN;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if key = VK_ESCAPE then
|
||||||
|
begin
|
||||||
|
if Field.IsNull then
|
||||||
|
CellEditor.Text := ''
|
||||||
|
else
|
||||||
|
CellEditor.Text := FormatDateTime(DisplayFormat, Field.AsDateTime);
|
||||||
updated := True;
|
updated := True;
|
||||||
|
theGrid.SetFocus; // No perder el foco
|
||||||
|
end
|
||||||
|
else
|
||||||
|
//if Key in [VK_UP, VK_DOWN] then
|
||||||
|
//begin
|
||||||
|
// Key := VK_UNKNOWN;
|
||||||
|
//end
|
||||||
|
//else
|
||||||
|
if Key in [VK_RETURN, VK_TAB, VK_UP, VK_DOWN] then
|
||||||
|
begin
|
||||||
|
CellEditor.Caption := NormalizeTime(CellEditor.Caption, theValue);
|
||||||
|
if Length(CellEditor.Caption) = 0 then
|
||||||
|
theValue := 0
|
||||||
|
else
|
||||||
|
if IsValidTimeString(CellEditor.Caption) then
|
||||||
|
begin
|
||||||
|
theValue := StrToTime(CellEditor.Caption);
|
||||||
|
Field.DataSet.Edit;
|
||||||
|
Field.Text := NormalizeTime(CellEditor.Caption, Field.AsDateTime);
|
||||||
|
CellEditor.SelectAll;
|
||||||
|
updated := True;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TJDbGridTimeCtrl.isNull: boolean;
|
function TJDbGridTimeCtrl.isNull: boolean;
|
||||||
@ -620,7 +621,7 @@ end;
|
|||||||
function TJDbGridTimeCtrl.CanDefocus: boolean;
|
function TJDbGridTimeCtrl.CanDefocus: boolean;
|
||||||
begin
|
begin
|
||||||
if not updated then
|
if not updated then
|
||||||
Result:= True
|
Result := True
|
||||||
else
|
else
|
||||||
if CellEditor.Focused and (Length(CellEditor.Text) = 0) then
|
if CellEditor.Focused and (Length(CellEditor.Text) = 0) then
|
||||||
Result := True
|
Result := True
|
||||||
@ -689,7 +690,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
ShowMessage(Format(SInvalidDate, [CellEditor.Caption]));
|
ShowMessage(Format(SInvalidDate, [CellEditor.Caption]));
|
||||||
if Field.IsNull then
|
if Field.IsNull then
|
||||||
CellEditor.Text:= ''
|
CellEditor.Text := ''
|
||||||
else
|
else
|
||||||
CellEditor.Text := FormatDateTime(DisplayFormat, Field.AsDateTime);
|
CellEditor.Text := FormatDateTime(DisplayFormat, Field.AsDateTime);
|
||||||
end;
|
end;
|
||||||
@ -734,7 +735,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
ShowMessage(Format(SInvalidDate, [CellEditor.Caption]));
|
ShowMessage(Format(SInvalidDate, [CellEditor.Caption]));
|
||||||
if Field.IsNull then
|
if Field.IsNull then
|
||||||
CellEditor.Text:= ''
|
CellEditor.Text := ''
|
||||||
else
|
else
|
||||||
CellEditor.Text := FormatDateTime(DisplayFormat, theValue);
|
CellEditor.Text := FormatDateTime(DisplayFormat, theValue);
|
||||||
CellEditor.SelectAll;
|
CellEditor.SelectAll;
|
||||||
@ -805,7 +806,7 @@ end;
|
|||||||
function TJDbGridDateCtrl.CanDefocus: boolean;
|
function TJDbGridDateCtrl.CanDefocus: boolean;
|
||||||
begin
|
begin
|
||||||
if not updated then
|
if not updated then
|
||||||
Result:= True
|
Result := True
|
||||||
else
|
else
|
||||||
if CellEditor.Focused and (Length(CellEditor.Text) = 0) then
|
if CellEditor.Focused and (Length(CellEditor.Text) = 0) then
|
||||||
Result := True
|
Result := True
|
||||||
@ -916,7 +917,7 @@ begin
|
|||||||
Field.DataSet.Edit;
|
Field.DataSet.Edit;
|
||||||
if decimals > 0 then
|
if decimals > 0 then
|
||||||
theValue := ScaleTo(theValue, fDecimals);
|
theValue := ScaleTo(theValue, fDecimals);
|
||||||
Field.Value := theValue; ;
|
Field.Value := theValue;
|
||||||
CellEditor.Text := Field.AsString;
|
CellEditor.Text := Field.AsString;
|
||||||
updated := True;
|
updated := True;
|
||||||
end;
|
end;
|
||||||
@ -1095,4 +1096,3 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user