mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-26 12:28:14 +02:00
IdeIntf, DBGridColumnsPropertyEditorForm: Simplify FillCollectionListBox etc. Issue #32903, patch from FTurtle.
git-svn-id: trunk@57098 -
This commit is contained in:
parent
082a0b0294
commit
9bf30fe379
@ -110,6 +110,8 @@ end;
|
|||||||
|
|
||||||
procedure TDBGridColumnsPropertyEditorForm.CollectionListBoxClick(Sender: TObject);
|
procedure TDBGridColumnsPropertyEditorForm.CollectionListBoxClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
// Do not use OnSelectionChange because it fires on changing ItemIndex by code
|
||||||
|
// (OnClick does not)
|
||||||
UpdateButtons;
|
UpdateButtons;
|
||||||
UpdateCaption;
|
UpdateCaption;
|
||||||
SelectInObjectInspector;
|
SelectInObjectInspector;
|
||||||
@ -298,6 +300,9 @@ begin
|
|||||||
actDel.Enabled := I > -1;
|
actDel.Enabled := I > -1;
|
||||||
actMoveUp.Enabled := I > 0;
|
actMoveUp.Enabled := I > 0;
|
||||||
actMoveDown.Enabled := (I >= 0) and (I < CollectionListBox.Items.Count - 1);
|
actMoveDown.Enabled := (I >= 0) and (I < CollectionListBox.Items.Count - 1);
|
||||||
|
DividerToolButton1.Visible := (FCollection is TDBGridColumns);
|
||||||
|
btAddFlds.Visible := DividerToolButton1.Visible;
|
||||||
|
actAddFields.Enabled := DividerToolButton1.Visible;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDBGridColumnsPropertyEditorForm.PersistentAdded(APersistent: TPersistent; Select: boolean);
|
procedure TDBGridColumnsPropertyEditorForm.PersistentAdded(APersistent: TPersistent; Select: boolean);
|
||||||
@ -333,37 +338,20 @@ end;
|
|||||||
|
|
||||||
procedure TDBGridColumnsPropertyEditorForm.FillCollectionListBox;
|
procedure TDBGridColumnsPropertyEditorForm.FillCollectionListBox;
|
||||||
var
|
var
|
||||||
I: Integer;
|
ItemIndex: Integer;
|
||||||
CurItem: String;
|
i: Integer;
|
||||||
Cnt: Integer;
|
|
||||||
begin
|
begin
|
||||||
CollectionListBox.Items.BeginUpdate;
|
CollectionListBox.Items.BeginUpdate;
|
||||||
try
|
try
|
||||||
if FCollection <> nil then
|
ItemIndex:=CollectionListBox.ItemIndex;
|
||||||
Cnt := FCollection.Count
|
CollectionListBox.Clear;
|
||||||
|
if FCollection<>nil then
|
||||||
|
for i:=0 to FCollection.Count-1 do
|
||||||
|
CollectionListBox.Items.Add(Format('%d - %s', [i, FCollection.Items[i].DisplayName]));
|
||||||
|
if ItemIndex<CollectionListBox.Count then
|
||||||
|
CollectionListBox.ItemIndex:=ItemIndex // OnClick not fires
|
||||||
else
|
else
|
||||||
Cnt := 0;
|
CollectionListBox.ItemIndex:=-1;
|
||||||
|
|
||||||
// add or replace list items
|
|
||||||
for I := 0 to Cnt - 1 do
|
|
||||||
begin
|
|
||||||
CurItem := IntToStr(I) + ' - ' + FCollection.Items[I].DisplayName;
|
|
||||||
|
|
||||||
DividerToolButton1.Visible := (FCollection is TDBGridColumns);
|
|
||||||
btAddFlds.Visible := DividerToolButton1.Visible;
|
|
||||||
actAddFields.Enabled := DividerToolButton1.Visible;
|
|
||||||
if I >= CollectionListBox.Items.Count then
|
|
||||||
CollectionListBox.Items.Add(CurItem)
|
|
||||||
else
|
|
||||||
CollectionListBox.Items[I] := CurItem;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// delete unneeded list items
|
|
||||||
if Cnt > 0 then
|
|
||||||
while CollectionListBox.Items.Count > Cnt do
|
|
||||||
CollectionListBox.Items.Delete(CollectionListBox.Items.Count - 1)
|
|
||||||
else
|
|
||||||
CollectionListBox.Items.Clear;
|
|
||||||
finally
|
finally
|
||||||
CollectionListBox.Items.EndUpdate;
|
CollectionListBox.Items.EndUpdate;
|
||||||
UpdateButtons;
|
UpdateButtons;
|
||||||
|
Loading…
Reference in New Issue
Block a user