IdeIntf, DBGridColumnsPropertyEditorForm: Remove useless properties. Issue #32903, patch from FTurtle.

git-svn-id: trunk@57071 -
This commit is contained in:
juha 2018-01-13 10:04:27 +00:00
parent 5ba536f2ab
commit d95cd50a49

View File

@ -67,11 +67,6 @@ type
procedure SetCollection(NewCollection: TCollection; procedure SetCollection(NewCollection: TCollection;
NewOwnerPersistent: TPersistent; const NewPropName: String); NewOwnerPersistent: TPersistent; const NewPropName: String);
procedure Modified; procedure Modified;
public
property Collection: TCollection read FCollection;
property OwnerComponent: TPersistent read FOwnerComponent;
property OwnerPersistent: TPersistent read FOwnerPersistent;
property PropertyName: String read FPropertyName;
end; end;
implementation implementation
@ -122,8 +117,8 @@ end;
procedure TDBGridColumnsPropertyEditorForm.actAddExecute(Sender: TObject); procedure TDBGridColumnsPropertyEditorForm.actAddExecute(Sender: TObject);
begin begin
if Collection = nil then Exit; if FCollection = nil then Exit;
Collection.Add; FCollection.Add;
FillCollectionListBox; FillCollectionListBox;
if CollectionListBox.Items.Count > 0 then if CollectionListBox.Items.Count > 0 then
@ -140,20 +135,20 @@ var
Item: TColumn; Item: TColumn;
i: Integer; i: Integer;
begin begin
if Collection=nil then Exit; if FCollection=nil then Exit;
if not (Collection is TDBGridColumns) then Exit; if not (FCollection is TDBGridColumns) then Exit;
DataSet:=GetDataSet; DataSet:=GetDataSet;
if DataSet=nil then Exit; if DataSet=nil then Exit;
if Collection.Count>0 then if FCollection.Count>0 then
if (MessageDlg(dceColumnEditor, dceOkToDelete, mtConfirmation, [mbYes, mbNo], 0) <> mrYes) then if (MessageDlg(dceColumnEditor, dceOkToDelete, mtConfirmation, [mbYes, mbNo], 0) <> mrYes) then
Exit; Exit;
try try
Collection.Clear; FCollection.Clear;
for i:=0 to DataSet.Fields.Count-1 do for i:=0 to DataSet.Fields.Count-1 do
begin begin
Item:=Collection.Add as TColumn; Item:=FCollection.Add as TColumn;
Item.Field:=DataSet.Fields[i]; Item.Field:=DataSet.Fields[i];
Item.Title.Caption:=DataSet.Fields[i].DisplayLabel; Item.Title.Caption:=DataSet.Fields[i].DisplayLabel;
end; end;
@ -167,13 +162,13 @@ end;
procedure TDBGridColumnsPropertyEditorForm.actDeleteAllExecute(Sender: TObject); procedure TDBGridColumnsPropertyEditorForm.actDeleteAllExecute(Sender: TObject);
begin begin
if Collection = nil then if FCollection = nil then
Exit; Exit;
if (MessageDlg(dceColumnEditor, dceOkToDelete, mtConfirmation, if (MessageDlg(dceColumnEditor, dceOkToDelete, mtConfirmation,
[mbYes, mbNo], 0) = mrYes) then [mbYes, mbNo], 0) = mrYes) then
try try
UnSelectInObjectInspector; UnSelectInObjectInspector;
Collection.Clear; FCollection.Clear;
finally finally
RefreshPropertyValues; RefreshPropertyValues;
UpdateButtons; UpdateButtons;
@ -186,11 +181,11 @@ procedure TDBGridColumnsPropertyEditorForm.actDelExecute(Sender: TObject);
var var
I : Integer; I : Integer;
begin begin
if Collection = nil then Exit; if FCollection = nil then Exit;
I := CollectionListBox.ItemIndex; I := CollectionListBox.ItemIndex;
if (I < 0) or (I >= Collection.Count) then Exit; if (I < 0) or (I >= FCollection.Count) then Exit;
if MessageDlg(oisConfirmDelete, if MessageDlg(oisConfirmDelete,
Format(oisDeleteItem, [Collection.Items[I].DisplayName]), Format(oisDeleteItem, [FCollection.Items[I].DisplayName]),
mtConfirmation, [mbYes, mbNo], 0) <> mrYes then mtConfirmation, [mbYes, mbNo], 0) <> mrYes then
Exit; Exit;
@ -198,7 +193,7 @@ begin
// unselect all items in OI (collections can act strange on delete) // unselect all items in OI (collections can act strange on delete)
UnSelectInObjectInspector; UnSelectInObjectInspector;
// now delete // now delete
Collection.Items[I].Free; FCollection.Items[I].Free;
// update listbox after whatever happened // update listbox after whatever happened
FillCollectionListBox; FillCollectionListBox;
// set new ItemIndex // set new ItemIndex
@ -241,12 +236,12 @@ procedure TDBGridColumnsPropertyEditorForm.actMoveDownExecute(Sender: TObject);
var var
I: Integer; I: Integer;
begin begin
if Collection = nil then Exit; if FCollection = nil then Exit;
I := CollectionListBox.ItemIndex; I := CollectionListBox.ItemIndex;
if I >= Collection.Count - 1 then Exit; if I >= FCollection.Count - 1 then Exit;
Collection.Items[I].Index := I + 1; FCollection.Items[I].Index := I + 1;
CollectionListBox.ItemIndex := I + 1; CollectionListBox.ItemIndex := I + 1;
FillCollectionListBox; FillCollectionListBox;
@ -258,12 +253,12 @@ procedure TDBGridColumnsPropertyEditorForm.actMoveUpExecute(Sender: TObject);
var var
I: Integer; I: Integer;
begin begin
if Collection = nil then Exit; if FCollection = nil then Exit;
I := CollectionListBox.ItemIndex; I := CollectionListBox.ItemIndex;
if I < 0 then Exit; if I < 0 then Exit;
Collection.Items[I].Index := I - 1; FCollection.Items[I].Index := I - 1;
CollectionListBox.ItemIndex := I - 1; CollectionListBox.ItemIndex := I - 1;
FillCollectionListBox; FillCollectionListBox;
@ -277,16 +272,16 @@ var
begin begin
//I think to match Delphi this should be formatted like //I think to match Delphi this should be formatted like
//"Editing ComponentName.PropertyName[Index]" //"Editing ComponentName.PropertyName[Index]"
if OwnerPersistent is TComponent then if FOwnerPersistent is TComponent then
NewCaption := TComponent(OwnerPersistent).Name NewCaption := TComponent(FOwnerPersistent).Name
else else
if OwnerPersistent <> nil then if FOwnerPersistent <> nil then
NewCaption := OwnerPersistent.GetNamePath NewCaption := FOwnerPersistent.GetNamePath
else else
NewCaption := ''; NewCaption := '';
if NewCaption <> '' then NewCaption := NewCaption + '.'; if NewCaption <> '' then NewCaption := NewCaption + '.';
NewCaption := oiColEditEditing + ' ' + NewCaption + PropertyName; NewCaption := oiColEditEditing + ' ' + NewCaption + FPropertyName;
if CollectionListBox.ItemIndex > -1 then if CollectionListBox.ItemIndex > -1 then
NewCaption := NewCaption + '[' + IntToStr(CollectionListBox.ItemIndex) + ']'; NewCaption := NewCaption + '[' + IntToStr(CollectionListBox.ItemIndex) + ']';
@ -298,7 +293,7 @@ var
I: Integer; I: Integer;
begin begin
I := CollectionListBox.ItemIndex; I := CollectionListBox.ItemIndex;
actAdd.Enabled := Collection <> nil; actAdd.Enabled := FCollection <> nil;
actFetchLabels.Enabled:=actAdd.Enabled and (CollectionListBox.Items.Count > 0); actFetchLabels.Enabled:=actAdd.Enabled and (CollectionListBox.Items.Count > 0);
actDel.Enabled := I > -1; actDel.Enabled := I > -1;
actMoveUp.Enabled := I > 0; actMoveUp.Enabled := I > 0;
@ -314,7 +309,7 @@ end;
procedure TDBGridColumnsPropertyEditorForm.ComponentRenamed(AComponent: TComponent); procedure TDBGridColumnsPropertyEditorForm.ComponentRenamed(AComponent: TComponent);
begin begin
//DebugLn('*** TDBGridColumnsPropertyEditorForm.ComponentRenamed called ***'); //DebugLn('*** TDBGridColumnsPropertyEditorForm.ComponentRenamed called ***');
if AComponent = OwnerPersistent then if AComponent = FOwnerPersistent then
UpdateCaption; UpdateCaption;
end; end;
@ -323,7 +318,7 @@ begin
// For some reason this is called only when the whole collection is deleted, // For some reason this is called only when the whole collection is deleted,
// for example when changing to another project. Thus clear the whole collection. // for example when changing to another project. Thus clear the whole collection.
DebugLn(['TDBGridColumnsPropertyEditorForm.PersistentDeleting: APersistent=', APersistent, DebugLn(['TDBGridColumnsPropertyEditorForm.PersistentDeleting: APersistent=', APersistent,
', OwnerPersistent=', OwnerPersistent, ', OwnerComponent=', OwnerComponent]); ', FOwnerPersistent=', FOwnerPersistent, ', FOwnerComponent=', FOwnerComponent]);
SetCollection(nil, nil, ''); SetCollection(nil, nil, '');
Hide; Hide;
UpdateButtons; UpdateButtons;
@ -344,17 +339,17 @@ var
begin begin
CollectionListBox.Items.BeginUpdate; CollectionListBox.Items.BeginUpdate;
try try
if Collection <> nil then if FCollection <> nil then
Cnt := Collection.Count Cnt := FCollection.Count
else else
Cnt := 0; Cnt := 0;
// add or replace list items // add or replace list items
for I := 0 to Cnt - 1 do for I := 0 to Cnt - 1 do
begin begin
CurItem := IntToStr(I) + ' - ' + Collection.Items[I].DisplayName;// +' '+ TDBGrid(TColumn(Collection.Items[I]).Grid).DataSource.DataSet.FieldByName( TColumn(Collection.Items[I]).FieldName ).DisplayLabel ;// + ' - '+Collection.Items[I].ClassName +' - ' + Collection.ClassName; CurItem := IntToStr(I) + ' - ' + FCollection.Items[I].DisplayName;
DividerToolButton1.Visible := (Collection is TDBGridColumns); DividerToolButton1.Visible := (FCollection is TDBGridColumns);
btAddFlds.Visible := DividerToolButton1.Visible; btAddFlds.Visible := DividerToolButton1.Visible;
actAddFields.Enabled := DividerToolButton1.Visible; actAddFields.Enabled := DividerToolButton1.Visible;
if I >= CollectionListBox.Items.Count then if I >= CollectionListBox.Items.Count then
@ -387,13 +382,13 @@ var
I: Integer; I: Integer;
NewSelection: TPersistentSelectionList; NewSelection: TPersistentSelectionList;
begin begin
Assert(Assigned(Collection), 'SelectInObjectInspector: Collection=Nil.'); Assert(Assigned(FCollection), 'SelectInObjectInspector: FCollection=Nil.');
// select in OI // select in OI
NewSelection := TPersistentSelectionList.Create; NewSelection := TPersistentSelectionList.Create;
try try
for I := 0 to CollectionListBox.Items.Count - 1 do for I := 0 to CollectionListBox.Items.Count - 1 do
if CollectionListBox.Selected[I] then if CollectionListBox.Selected[I] then
NewSelection.Add(Collection.Items[I]); NewSelection.Add(FCollection.Items[I]);
UpdDesignHook(NewSelection); UpdDesignHook(NewSelection);
finally finally
NewSelection.Free; NewSelection.Free;
@ -416,7 +411,7 @@ procedure TDBGridColumnsPropertyEditorForm.UpdDesignHook(aSelection: TPersistent
begin begin
if GlobalDesignHook = nil then Exit; if GlobalDesignHook = nil then Exit;
GlobalDesignHook.SetSelection(aSelection); GlobalDesignHook.SetSelection(aSelection);
GlobalDesignHook.LookupRoot := GetLookupRootForComponent(OwnerPersistent); GlobalDesignHook.LookupRoot := GetLookupRootForComponent(FOwnerPersistent);
end; end;
procedure TDBGridColumnsPropertyEditorForm.SetCollection(NewCollection: TCollection; procedure TDBGridColumnsPropertyEditorForm.SetCollection(NewCollection: TCollection;
@ -436,7 +431,7 @@ begin
break; break;
FOwnerComponent := TPersistentAccess(FOwnerComponent).GetOwner; FOwnerComponent := TPersistentAccess(FOwnerComponent).GetOwner;
end; end;
//debugln('TDBGridColumnsPropertyEditorForm.SetCollection A Collection=',dbgsName(FCollection),' OwnerPersistent=',dbgsName(OwnerPersistent),' PropName=',PropertyName); //debugln('TDBGridColumnsPropertyEditorForm.SetCollection A Collection=',dbgsName(FCollection),' OwnerPersistent=',dbgsName(FOwnerPersistent),' PropName=',FPropertyName);
if GlobalDesignHook <> nil then if GlobalDesignHook <> nil then
begin begin
GlobalDesignHook.RemoveAllHandlersForObject(Self); GlobalDesignHook.RemoveAllHandlersForObject(Self);