RxFPC:TRxMemoryData - fix copy strcture if component plased on TFrame

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7324 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2020-02-07 08:02:52 +00:00
parent 6f4d0213ea
commit 681a531c54
2 changed files with 38 additions and 20 deletions

View File

@ -9,15 +9,15 @@ object SelectDataSetForm: TSelectDataSetForm
ClientWidth = 400
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '1.3'
LCLVersion = '2.1.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = CheckBox1
AnchorSideTop.Side = asrBottom
Left = 6
Height = 21
Height = 17
Top = 35
Width = 98
Width = 89
BorderSpacing.Around = 6
Caption = 'Sourse dataset'
FocusControl = DataSetList
@ -29,7 +29,7 @@ object SelectDataSetForm: TSelectDataSetForm
Left = 6
Height = 23
Top = 6
Width = 154
Width = 147
BorderSpacing.Around = 6
Caption = 'Copy only metadata'
OnChange = CheckBox1Change
@ -43,8 +43,8 @@ object SelectDataSetForm: TSelectDataSetForm
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ButtonPanel1
Left = 6
Height = 200
Top = 62
Height = 199
Top = 58
Width = 388
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
@ -57,8 +57,8 @@ object SelectDataSetForm: TSelectDataSetForm
end
object ButtonPanel1: TButtonPanel
Left = 6
Height = 41
Top = 268
Height = 46
Top = 263
Width = 388
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True

View File

@ -56,7 +56,7 @@ type
FDesigner: TComponentEditorDesigner;
FExclude: string;
procedure FillDataSetList(ExcludeDataSet: TDataSet);
procedure AddDataSet(const S: string);
procedure AddDataSet(const S: string; ADS:TDataSet);
public
{ public declarations }
end;
@ -100,10 +100,7 @@ begin
FillDataSetList(ExcludeDataSet);
if ShowModal = mrOk then
if DataSetList.ItemIndex >= 0 then
begin
with DataSetList do
Result := FDesigner.Form.FindComponent(Items[ItemIndex]) as TDataSet;
end;
Result := DataSetList.Items.Objects[DataSetList.ItemIndex] as TDataSet;
finally
Free;
end;
@ -138,19 +135,39 @@ end;
procedure TSelectDataSetForm.FillDataSetList(ExcludeDataSet: TDataSet);
var
I: Integer;
Component: TComponent;
Component, F: TComponent;
begin
DataSetList.Items.BeginUpdate;
try
DataSetList.Clear;
FExclude := '';
if ExcludeDataSet <> nil then FExclude := ExcludeDataSet.Name;
for I := 0 to FDesigner.Form.ComponentCount - 1 do
if FDesigner.Form.ComponentCount > 0 then
begin
Component := FDesigner.Form.Components[I];
if (Component is TDataSet) and (Component <> ExcludeDataSet) then
AddDataSet(Component.Name);
for I := 0 to FDesigner.Form.ComponentCount - 1 do
begin
Component := FDesigner.Form.Components[I];
if (Component is TDataSet) and (Component <> ExcludeDataSet) then
AddDataSet(Component.Name, TDataSet(Component));
end;
end
else
begin
F:=ExcludeDataSet.Owner;
while Assigned(F) and not((F is TForm) or (F is TFrame) or (F is TDataModule)) do F:=F.Owner;
if Assigned(F) then
begin
for I := 0 to F.ComponentCount - 1 do
begin
Component := F.Components[I];
if (Component is TDataSet) and (Component <> ExcludeDataSet) then
AddDataSet(Component.Name, TDataSet(Component));
end;
end;
end;
with DataSetList do
begin
if Items.Count > 0 then ItemIndex := 0;
@ -162,9 +179,10 @@ begin
end;
end;
procedure TSelectDataSetForm.AddDataSet(const S: string);
procedure TSelectDataSetForm.AddDataSet(const S: string; ADS: TDataSet);
begin
if (S <> '') and (S <> FExclude) then DataSetList.Items.Add(S);
if (S <> '') and (S <> FExclude) then
DataSetList.Items.AddObject(S, ADS);
end;
{ TMemDataSetEditor }