diff --git a/components/rx/rxdbgrid.pas b/components/rx/rxdbgrid.pas index 41b52aebf..862181cbe 100644 --- a/components/rx/rxdbgrid.pas +++ b/components/rx/rxdbgrid.pas @@ -469,7 +469,7 @@ type FSortColumns: TRxDbGridColumnsSortList; FSortingNow:Boolean; FInProcessCalc: integer; - FAllowedOperations: TRxDBGridAllowedOperations; +// FAllowedOperations: TRxDBGridAllowedOperations; // FKeyStrokes: TRxDBGridKeyStrokes; FOnGetCellProps: TGetCellPropsEvent; @@ -523,6 +523,7 @@ type FOldDataSetState:TDataSetState; procedure DoCreateJMenu; + function GetAllowedOperations: TRxDBGridAllowedOperations; function GetColumns: TRxDbGridColumns; function GetFooterColor: TColor; function GetFooterRowCount: integer; @@ -533,6 +534,7 @@ type function GetSortOrder: TSortMarker; function GetTitleButtons: boolean; function IsColumnsStored: boolean; + procedure SetAllowedOperations(AValue: TRxDBGridAllowedOperations); procedure SetAutoSort(const AValue: boolean); procedure SetColumns(const AValue: TRxDbGridColumns); procedure SetFooterColor(const AValue: TColor); @@ -712,8 +714,7 @@ type read GetPropertyStorage write SetPropertyStorage; property Version: integer read FVersion write FVersion default 0; property AllowedOperations: TRxDBGridAllowedOperations - read FAllowedOperations write FAllowedOperations default - [aoInsert, aoUpdate, aoDelete, aoAppend]; + read GetAllowedOperations write SetAllowedOperations default [aoInsert, aoUpdate, aoDelete, aoAppend]; deprecated; property OptionsRx: TOptionsRx read FOptionsRx write SetOptionsRx; property FooterColor: TColor read GetFooterColor write SetFooterColor default clWindow; deprecated; property FooterRowCount: integer read GetFooterRowCount write SetFooterRowCount default 0; deprecated; @@ -1696,6 +1697,22 @@ begin CreateMenuItem('A', sRxDBGridSelectAllRows, @OnSelectAllRows); end; +function TRxDBGrid.GetAllowedOperations: TRxDBGridAllowedOperations; +begin +// Result:=FAllowedOperations; + if dgDisableInsert in Options then + Result:=Result - [aoInsert, aoAppend] + else + Result:=Result + [aoInsert, aoAppend] + ; + + if dgDisableDelete in Options then + Result:=Result - [aoDelete] + else + Result:=Result + [aoDelete] + ; +end; + function TRxDBGrid.GetPropertyStorage: TCustomPropertyStorage; begin Result := FPropertyStorageLink.Storage; @@ -1727,6 +1744,20 @@ begin Result := TRxDbGridColumns(TCustomDrawGrid(Self).Columns).Enabled; end; +procedure TRxDBGrid.SetAllowedOperations(AValue: TRxDBGridAllowedOperations); +begin +// FAllowedOperations:=AValue; + if [aoInsert, aoAppend] * AValue <> [aoInsert, aoAppend] then + Options:=Options - [dgDisableInsert] + else + Options:=Options + [dgDisableInsert]; + + if aoDelete in AValue then + Options:=Options - [dgDisableDelete] + else + Options:=Options + [dgDisableDelete] +end; + procedure TRxDBGrid.SetColumns(const AValue: TRxDbGridColumns); begin TRxDbGridColumns(TCustomDrawGrid(Self).Columns).Assign(Avalue); @@ -3467,8 +3498,8 @@ begin if (Key in CCancelQuickSearchKeys) then if Length(QuickUTF8Search) > 0 then QuickUTF8Search := ''; - case Key of - VK_DELETE: if not (aoDelete in FAllowedOperations) then +(* case Key of +{ VK_DELETE: if not (aoDelete in FAllowedOperations) then exit; VK_INSERT: if not (aoInsert in FAllowedOperations) then exit; @@ -3495,14 +3526,17 @@ begin begin FTmpReadOnly := ReadOnly; ReadOnly := True; - inherited KeyDown(Key, Shift); - ReadOnly := FTmpReadOnly; + try + inherited KeyDown(Key, Shift); + finally + ReadOnly := FTmpReadOnly; + end; exit; - end + end } { else UpdateRowsHeight; - VK_UP:UpdateRowsHeight}; - end; + VK_UP:UpdateRowsHeight} + end; *) inherited KeyDown(Key, Shift); if Key <> 0 then begin @@ -4438,7 +4472,7 @@ begin FPropertyStorageLink.OnSave := @OnIniSave; FPropertyStorageLink.OnLoad := @OnIniLoad; - FAllowedOperations := [aoInsert, aoUpdate, aoDelete, aoAppend]; +// FAllowedOperations := [aoInsert, aoUpdate, aoDelete, aoAppend]; FFilterListEditor := TFilterListCellEditor.Create(nil); with FFilterListEditor do diff --git a/components/rx/version/2.1/rxdbgrid.pas b/components/rx/version/2.1/rxdbgrid.pas index 41b52aebf..862181cbe 100644 --- a/components/rx/version/2.1/rxdbgrid.pas +++ b/components/rx/version/2.1/rxdbgrid.pas @@ -469,7 +469,7 @@ type FSortColumns: TRxDbGridColumnsSortList; FSortingNow:Boolean; FInProcessCalc: integer; - FAllowedOperations: TRxDBGridAllowedOperations; +// FAllowedOperations: TRxDBGridAllowedOperations; // FKeyStrokes: TRxDBGridKeyStrokes; FOnGetCellProps: TGetCellPropsEvent; @@ -523,6 +523,7 @@ type FOldDataSetState:TDataSetState; procedure DoCreateJMenu; + function GetAllowedOperations: TRxDBGridAllowedOperations; function GetColumns: TRxDbGridColumns; function GetFooterColor: TColor; function GetFooterRowCount: integer; @@ -533,6 +534,7 @@ type function GetSortOrder: TSortMarker; function GetTitleButtons: boolean; function IsColumnsStored: boolean; + procedure SetAllowedOperations(AValue: TRxDBGridAllowedOperations); procedure SetAutoSort(const AValue: boolean); procedure SetColumns(const AValue: TRxDbGridColumns); procedure SetFooterColor(const AValue: TColor); @@ -712,8 +714,7 @@ type read GetPropertyStorage write SetPropertyStorage; property Version: integer read FVersion write FVersion default 0; property AllowedOperations: TRxDBGridAllowedOperations - read FAllowedOperations write FAllowedOperations default - [aoInsert, aoUpdate, aoDelete, aoAppend]; + read GetAllowedOperations write SetAllowedOperations default [aoInsert, aoUpdate, aoDelete, aoAppend]; deprecated; property OptionsRx: TOptionsRx read FOptionsRx write SetOptionsRx; property FooterColor: TColor read GetFooterColor write SetFooterColor default clWindow; deprecated; property FooterRowCount: integer read GetFooterRowCount write SetFooterRowCount default 0; deprecated; @@ -1696,6 +1697,22 @@ begin CreateMenuItem('A', sRxDBGridSelectAllRows, @OnSelectAllRows); end; +function TRxDBGrid.GetAllowedOperations: TRxDBGridAllowedOperations; +begin +// Result:=FAllowedOperations; + if dgDisableInsert in Options then + Result:=Result - [aoInsert, aoAppend] + else + Result:=Result + [aoInsert, aoAppend] + ; + + if dgDisableDelete in Options then + Result:=Result - [aoDelete] + else + Result:=Result + [aoDelete] + ; +end; + function TRxDBGrid.GetPropertyStorage: TCustomPropertyStorage; begin Result := FPropertyStorageLink.Storage; @@ -1727,6 +1744,20 @@ begin Result := TRxDbGridColumns(TCustomDrawGrid(Self).Columns).Enabled; end; +procedure TRxDBGrid.SetAllowedOperations(AValue: TRxDBGridAllowedOperations); +begin +// FAllowedOperations:=AValue; + if [aoInsert, aoAppend] * AValue <> [aoInsert, aoAppend] then + Options:=Options - [dgDisableInsert] + else + Options:=Options + [dgDisableInsert]; + + if aoDelete in AValue then + Options:=Options - [dgDisableDelete] + else + Options:=Options + [dgDisableDelete] +end; + procedure TRxDBGrid.SetColumns(const AValue: TRxDbGridColumns); begin TRxDbGridColumns(TCustomDrawGrid(Self).Columns).Assign(Avalue); @@ -3467,8 +3498,8 @@ begin if (Key in CCancelQuickSearchKeys) then if Length(QuickUTF8Search) > 0 then QuickUTF8Search := ''; - case Key of - VK_DELETE: if not (aoDelete in FAllowedOperations) then +(* case Key of +{ VK_DELETE: if not (aoDelete in FAllowedOperations) then exit; VK_INSERT: if not (aoInsert in FAllowedOperations) then exit; @@ -3495,14 +3526,17 @@ begin begin FTmpReadOnly := ReadOnly; ReadOnly := True; - inherited KeyDown(Key, Shift); - ReadOnly := FTmpReadOnly; + try + inherited KeyDown(Key, Shift); + finally + ReadOnly := FTmpReadOnly; + end; exit; - end + end } { else UpdateRowsHeight; - VK_UP:UpdateRowsHeight}; - end; + VK_UP:UpdateRowsHeight} + end; *) inherited KeyDown(Key, Shift); if Key <> 0 then begin @@ -4438,7 +4472,7 @@ begin FPropertyStorageLink.OnSave := @OnIniSave; FPropertyStorageLink.OnLoad := @OnIniLoad; - FAllowedOperations := [aoInsert, aoUpdate, aoDelete, aoAppend]; +// FAllowedOperations := [aoInsert, aoUpdate, aoDelete, aoAppend]; FFilterListEditor := TFilterListCellEditor.Create(nil); with FFilterListEditor do