mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Remove helper function ToggleCheckListBox, replace the few callers with simple code alternatives
This commit is contained in:
@ -54,14 +54,11 @@ procedure TColumnSelectionForm.FormShow(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=0 to Mainform.SelectedTableColumns.Count-1 do
|
||||
for i:=0 to Mainform.SelectedTableColumns.Count-1 do begin
|
||||
chklistColumns.Items.Add(Mainform.SelectedTableColumns[i].Name);
|
||||
|
||||
// Check items!
|
||||
if Mainform.DataGridHiddenColumns.Count = 0 then // Simply check all items
|
||||
ToggleCheckListBox( chklistColumns, True )
|
||||
else // Only check selected items
|
||||
ToggleCheckListBox( chklistColumns, False, Mainform.DataGridHiddenColumns );
|
||||
chklistColumns.Checked[i] := (Mainform.DataGridHiddenColumns.Count = 0) or
|
||||
(Mainform.DataGridHiddenColumns.IndexOf(chklistColumns.Items[i]) = -1);
|
||||
end;
|
||||
|
||||
// Call check-event to update state of "Select / Deselect all" checkbox
|
||||
chklistColumnsClickCheck( Sender );
|
||||
@ -96,10 +93,13 @@ end;
|
||||
Select / Deselect all
|
||||
}
|
||||
procedure TColumnSelectionForm.chkSelectAllClick(Sender: TObject);
|
||||
var
|
||||
cb: TCheckBox;
|
||||
begin
|
||||
// Avoid executing when checkbox was toggled by code (see proc below)
|
||||
if (Sender as TCheckBox).Focused then
|
||||
ToggleCheckListBox( chklistColumns, (Sender as TCheckBox).Checked );
|
||||
cb := Sender as TCheckBox;
|
||||
if cb.Focused then
|
||||
chklistColumns.CheckAll(cb.State);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -944,6 +944,7 @@ end;
|
||||
function TSetEditorLink.PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex): Boolean; stdcall;
|
||||
var
|
||||
SelValues: TStringList;
|
||||
i: Integer;
|
||||
begin
|
||||
Result := inherited PrepareEdit(Tree, Node, Column);
|
||||
if not Result then
|
||||
@ -955,7 +956,10 @@ begin
|
||||
SelValues.Delimiter := ',';
|
||||
SelValues.StrictDelimiter := True;
|
||||
SelValues.DelimitedText := FCellText;
|
||||
ToggleCheckListBox(FCheckList, True, SelValues);
|
||||
for i:=0 to FCheckList.Items.Count-1 do begin
|
||||
FCheckList.Checked[i] := SelValues.IndexOf(FCheckList.Items[i]) > -1;
|
||||
end;
|
||||
SelValues.Free;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -145,8 +145,6 @@ type
|
||||
function BestTableName(Data: TDBQuery): String;
|
||||
function urlencode(url: String): String;
|
||||
procedure StreamWrite(S: TStream; Text: String = '');
|
||||
procedure ToggleCheckListBox(list: TCheckListBox; state: Boolean); Overload;
|
||||
procedure ToggleCheckListBox(list: TCheckListBox; state: Boolean; list_toggle: TStringList); Overload;
|
||||
function _GetFileSize(Filename: String): Int64;
|
||||
function MakeInt( Str: String ) : Int64;
|
||||
function MakeFloat( Str: String ): Extended;
|
||||
@ -431,46 +429,6 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{***
|
||||
Check/Uncheck all items in a CheckListBox
|
||||
|
||||
@param TCheckListBox List with checkable items
|
||||
@param boolean Check them?
|
||||
@return void
|
||||
}
|
||||
procedure ToggleCheckListBox(list: TCheckListBox; state: Boolean);
|
||||
var
|
||||
i : Integer;
|
||||
begin
|
||||
// select all/none
|
||||
for i:=0 to list.Items.Count-1 do
|
||||
list.checked[i] := state;
|
||||
end;
|
||||
|
||||
|
||||
{***
|
||||
Check/Uncheck items in a CheckListBox which come in a second list
|
||||
|
||||
@param TCheckListBox List with checkable items
|
||||
@param boolean Check them?
|
||||
@param TStringList Second list with items to change
|
||||
@return void
|
||||
}
|
||||
procedure ToggleCheckListBox(list: TCheckListBox; state: Boolean; list_toggle: TStringList);
|
||||
var
|
||||
i : Integer;
|
||||
begin
|
||||
for i:=0 to list.Items.Count-1 do begin
|
||||
if list_toggle.IndexOf(list.Items[i]) > -1 then
|
||||
list.Checked[i] := state
|
||||
else
|
||||
list.Checked[i] := not state;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{***
|
||||
Return filesize of a given file
|
||||
@param string Filename
|
||||
|
Reference in New Issue
Block a user