From 51487a0dd59eb6a343b2cfeb629a6748ad6f8b09 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 24 Feb 2010 07:27:27 +0000 Subject: [PATCH] ideintf: fix collection items position after move up/move down in the collection editor (bug #0015570) git-svn-id: trunk@23773 - --- ideintf/collectionpropeditform.pas | 17 ++++++++------- ideintf/componenttreeview.pas | 8 +++---- ideintf/objectinspector.pp | 34 +++++++++++++++--------------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/ideintf/collectionpropeditform.pas b/ideintf/collectionpropeditform.pas index c68c30e4c2..de5e0e880b 100644 --- a/ideintf/collectionpropeditform.pas +++ b/ideintf/collectionpropeditform.pas @@ -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 diff --git a/ideintf/componenttreeview.pas b/ideintf/componenttreeview.pas index 3c944cc749..c922344a49 100644 --- a/ideintf/componenttreeview.pas +++ b/ideintf/componenttreeview.pas @@ -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; diff --git a/ideintf/objectinspector.pp b/ideintf/objectinspector.pp index 4d16450b03..335ccf1108 100644 --- a/ideintf/objectinspector.pp +++ b/ideintf/objectinspector.pp @@ -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);