ideintf: fix collection items position after move up/move down in the collection editor (bug #0015570)

git-svn-id: trunk@23773 -
This commit is contained in:
paul 2010-02-24 07:27:27 +00:00
parent 4ca87431d7
commit 51487a0dd5
3 changed files with 30 additions and 29 deletions

View File

@ -37,7 +37,7 @@ type
procedure RefreshPropertyValues;
public
procedure FillCollectionListBox;
procedure SelectInObjectInspector(UnselectAll: Boolean);
procedure SelectInObjectInspector(ForceUpdate, UnselectAll: Boolean);
procedure SetCollection(NewCollection: TCollection;
NewOwnerPersistent: TPersistent; const NewPropName: String);
procedure Modified;
@ -86,7 +86,7 @@ begin
CollectionListBox.ItemIndex := I + 1;
FillCollectionListBox;
SelectInObjectInspector(False);
SelectInObjectInspector(True, False);
Modified;
end;
@ -103,7 +103,7 @@ begin
CollectionListBox.ItemIndex := I - 1;
FillCollectionListBox;
SelectInObjectInspector(False);
SelectInObjectInspector(True, False);
Modified;
end;
@ -115,7 +115,7 @@ begin
FillCollectionListBox;
if CollectionListBox.Items.Count > 0 then
CollectionListBox.ItemIndex := CollectionListBox.Items.Count - 1;
SelectInObjectInspector(False);
SelectInObjectInspector(True, False);
UpdateButtons;
UpdateCaption;
Modified;
@ -125,7 +125,7 @@ procedure TCollectionPropertyEditorForm.CollectionListBoxClick(Sender: TObject);
begin
UpdateButtons;
UpdateCaption;
SelectInObjectInspector(False);
SelectInObjectInspector(False, False);
end;
procedure TCollectionPropertyEditorForm.DeleteButtonClick(Sender: TObject);
@ -161,7 +161,7 @@ begin
if NewItemIndex > I then Dec(NewItemIndex);
//debugln('TCollectionPropertyEditorForm.DeleteClick A NewItemIndex=',dbgs(NewItemIndex),' ItemIndex=',dbgs(CollectionListBox.ItemIndex),' CollectionListBox.Items.Count=',dbgs(CollectionListBox.Items.Count),' Collection.Count=',dbgs(Collection.Count));
// unselect all items in OI (collections can act strange on delete)
SelectInObjectInspector(True);
SelectInObjectInspector(True, True);
// now delete
Collection.Items[I].Free;
// update listbox after whatever happened
@ -170,7 +170,7 @@ begin
if NewItemIndex < CollectionListBox.Items.Count then
begin
CollectionListBox.ItemIndex := NewItemIndex;
SelectInObjectInspector(False);
SelectInObjectInspector(False, False);
end;
//debugln('TCollectionPropertyEditorForm.DeleteClick B');
Modified;
@ -280,7 +280,7 @@ begin
end;
end;
procedure TCollectionPropertyEditorForm.SelectInObjectInspector(UnselectAll: Boolean);
procedure TCollectionPropertyEditorForm.SelectInObjectInspector(ForceUpdate, UnselectAll: Boolean);
var
I: Integer;
NewSelection: TPersistentSelectionList;
@ -288,6 +288,7 @@ begin
if Collection = nil then Exit;
// select in OI
NewSelection := TPersistentSelectionList.Create;
NewSelection.ForceUpdate := ForceUpdate;
try
if not UnselectAll then
begin

View File

@ -658,11 +658,11 @@ procedure TComponentTreeView.UpdateComponentNodesValues;
procedure UpdateComponentNode(ANode: TTreeNode);
var
AComponent: TComponent;
APersistent: TPersistent;
begin
if ANode=nil then exit;
AComponent:=TComponent(ANode.Data);
ANode.Text:=CreateNodeCaption(AComponent);
if ANode = nil then Exit;
APersistent := TPersistent(ANode.Data);
ANode.Text := CreateNodeCaption(APersistent);
UpdateComponentNode(ANode.GetFirstChild);
UpdateComponentNode(ANode.GetNextSibling);
end;

View File

@ -687,6 +687,8 @@ type
procedure DoComponentEditorVerbMenuItemClick(Sender: TObject);
procedure DoCollectionAddItem(Sender: TObject);
procedure DoZOrderItemClick(Sender: TObject);
private
FInSelection: Boolean;
protected
function PersistentToString(APersistent: TPersistent): string;
procedure AddPersistentToList(APersistent: TPersistent; List: TStrings);
@ -3800,6 +3802,7 @@ constructor TObjectInspectorDlg.Create(AnOwner: TComponent);
begin
inherited Create(AnOwner);
FPropertyEditorHook:=nil;
FInSelection := False;
FSelection:=TPersistentSelectionList.Create;
FAutoShow := True;
FUpdatingAvailComboBox:=false;
@ -4135,15 +4138,18 @@ end;
procedure TObjectInspectorDlg.SetSelection(const ASelection: TPersistentSelectionList);
begin
if not ASelection.ForceUpdate and FSelection.IsEqual(ASelection) then
if not Assigned(ASelection) or FInSelection or (not ASelection.ForceUpdate and FSelection.IsEqual(ASelection)) then
Exit;
//if (FSelection.Count=1) and (FSelection[0] is TCollectionItem)
//and (ASelection.Count=0) then RaiseGDBException('');
FSelection.Assign(ASelection);
SetAvailComboBoxText;
RefreshSelection;
if Assigned(FOnSelectPersistentsInOI) then
FOnSelectPersistentsInOI(Self);
FInSelection := True;
try
FSelection.Assign(ASelection);
SetAvailComboBoxText;
RefreshSelection;
if Assigned(FOnSelectPersistentsInOI) then
FOnSelectPersistentsInOI(Self);
finally
FInSelection := False;
end;
end;
procedure TObjectInspectorDlg.RefreshSelection;
@ -4506,21 +4512,15 @@ begin
end;
end;
procedure TObjectInspectorDlg.HookGetSelection(
const ASelection: TPersistentSelectionList);
procedure TObjectInspectorDlg.HookGetSelection(const ASelection: TPersistentSelectionList);
begin
if ASelection=nil then exit;
ASelection.Assign(FSelection);
end;
procedure TObjectInspectorDlg.HookSetSelection(
const ASelection: TPersistentSelectionList);
procedure TObjectInspectorDlg.HookSetSelection(const ASelection: TPersistentSelectionList);
begin
if ASelection=nil then exit;
if FSelection.IsEqual(ASelection) then exit;
Selection:=ASelection;
if Assigned(FOnSelectPersistentsInOI) then
FOnSelectPersistentsInOI(Self);
Selection := ASelection;
end;
procedure TObjectInspectorDlg.SetShowComponentTree(const AValue: boolean);