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

View File

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