mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 07:19:18 +02:00
IdeIntf: Simplify TDBGridColumnsPropertyEditorForm.actDelExecute.
git-svn-id: trunk@57052 -
This commit is contained in:
parent
1bb9a00738
commit
68c9678a8a
@ -205,51 +205,32 @@ end;
|
|||||||
procedure TDBGridColumnsPropertyEditorForm.actDelExecute(Sender: TObject);
|
procedure TDBGridColumnsPropertyEditorForm.actDelExecute(Sender: TObject);
|
||||||
var
|
var
|
||||||
I : Integer;
|
I : Integer;
|
||||||
NewItemIndex: Integer;
|
|
||||||
begin
|
begin
|
||||||
if Collection = nil then Exit;
|
if Collection = nil then Exit;
|
||||||
|
|
||||||
I := CollectionListBox.ItemIndex;
|
I := CollectionListBox.ItemIndex;
|
||||||
if (I >= 0) and (I < Collection.Count) then
|
if (I < 0) or (I >= Collection.Count) then Exit;
|
||||||
|
if MessageDlg(oisConfirmDelete,
|
||||||
|
Format(oisDeleteItem, [Collection.Items[I].DisplayName]),
|
||||||
|
mtConfirmation, [mbYes, mbNo], 0) <> mrYes then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
CollectionListBox.ItemIndex := -1;
|
||||||
|
// unselect all items in OI (collections can act strange on delete)
|
||||||
|
UnSelectInObjectInspector;
|
||||||
|
// now delete
|
||||||
|
Collection.Items[I].Free;
|
||||||
|
// update listbox after whatever happened
|
||||||
|
FillCollectionListBox;
|
||||||
|
// set new ItemIndex
|
||||||
|
if I >= CollectionListBox.Items.Count then
|
||||||
|
I := CollectionListBox.Items.Count-1;
|
||||||
|
if I >= 0 then
|
||||||
begin
|
begin
|
||||||
if MessageDlg(oisConfirmDelete,
|
CollectionListBox.ItemIndex := I;
|
||||||
Format(oisDeleteItem, [Collection.Items[I].DisplayName]),
|
SelectInObjectInspector;
|
||||||
mtConfirmation, [mbYes, mbNo], 0) = mrYes then
|
|
||||||
begin
|
|
||||||
// select other item, or unselect
|
|
||||||
NewItemIndex := I + 1;
|
|
||||||
while (NewItemIndex < CollectionListBox.Items.Count)
|
|
||||||
and (CollectionListBox.Selected[NewItemIndex]) do Inc(NewItemIndex);
|
|
||||||
|
|
||||||
if NewItemIndex = CollectionListBox.Items.Count then
|
|
||||||
begin
|
|
||||||
NewItemIndex := 0;
|
|
||||||
while (NewItemIndex < Pred(I))
|
|
||||||
and not (CollectionListBox.Selected[NewItemIndex]) do Inc(NewItemIndex);
|
|
||||||
|
|
||||||
if NewItemIndex = I then NewItemIndex := -1;
|
|
||||||
end;
|
|
||||||
|
|
||||||
CollectionListBox.ItemIndex := -1;
|
|
||||||
|
|
||||||
if NewItemIndex > I then Dec(NewItemIndex);
|
|
||||||
//debugln('TDBGridColumnsPropertyEditorForm.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)
|
|
||||||
UnSelectInObjectInspector;
|
|
||||||
// now delete
|
|
||||||
Collection.Items[I].Free;
|
|
||||||
// update listbox after whatever happened
|
|
||||||
FillCollectionListBox;
|
|
||||||
// set NewItemIndex
|
|
||||||
if NewItemIndex < CollectionListBox.Items.Count then
|
|
||||||
begin
|
|
||||||
CollectionListBox.ItemIndex := NewItemIndex;
|
|
||||||
SelectInObjectInspector;
|
|
||||||
end;
|
|
||||||
//debugln('TDBGridColumnsPropertyEditorForm.DeleteClick B');
|
|
||||||
Modified;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
//debugln('TDBGridColumnsPropertyEditorForm.DeleteClick B');
|
||||||
|
Modified;
|
||||||
UpdateButtons;
|
UpdateButtons;
|
||||||
UpdateCaption;
|
UpdateCaption;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user