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
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
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);
|
chklistColumns.Items.Add(Mainform.SelectedTableColumns[i].Name);
|
||||||
|
chklistColumns.Checked[i] := (Mainform.DataGridHiddenColumns.Count = 0) or
|
||||||
// Check items!
|
(Mainform.DataGridHiddenColumns.IndexOf(chklistColumns.Items[i]) = -1);
|
||||||
if Mainform.DataGridHiddenColumns.Count = 0 then // Simply check all items
|
end;
|
||||||
ToggleCheckListBox( chklistColumns, True )
|
|
||||||
else // Only check selected items
|
|
||||||
ToggleCheckListBox( chklistColumns, False, Mainform.DataGridHiddenColumns );
|
|
||||||
|
|
||||||
// Call check-event to update state of "Select / Deselect all" checkbox
|
// Call check-event to update state of "Select / Deselect all" checkbox
|
||||||
chklistColumnsClickCheck( Sender );
|
chklistColumnsClickCheck( Sender );
|
||||||
@ -96,10 +93,13 @@ end;
|
|||||||
Select / Deselect all
|
Select / Deselect all
|
||||||
}
|
}
|
||||||
procedure TColumnSelectionForm.chkSelectAllClick(Sender: TObject);
|
procedure TColumnSelectionForm.chkSelectAllClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
cb: TCheckBox;
|
||||||
begin
|
begin
|
||||||
// Avoid executing when checkbox was toggled by code (see proc below)
|
// Avoid executing when checkbox was toggled by code (see proc below)
|
||||||
if (Sender as TCheckBox).Focused then
|
cb := Sender as TCheckBox;
|
||||||
ToggleCheckListBox( chklistColumns, (Sender as TCheckBox).Checked );
|
if cb.Focused then
|
||||||
|
chklistColumns.CheckAll(cb.State);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -944,6 +944,7 @@ end;
|
|||||||
function TSetEditorLink.PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex): Boolean; stdcall;
|
function TSetEditorLink.PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex): Boolean; stdcall;
|
||||||
var
|
var
|
||||||
SelValues: TStringList;
|
SelValues: TStringList;
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
Result := inherited PrepareEdit(Tree, Node, Column);
|
Result := inherited PrepareEdit(Tree, Node, Column);
|
||||||
if not Result then
|
if not Result then
|
||||||
@ -955,7 +956,10 @@ begin
|
|||||||
SelValues.Delimiter := ',';
|
SelValues.Delimiter := ',';
|
||||||
SelValues.StrictDelimiter := True;
|
SelValues.StrictDelimiter := True;
|
||||||
SelValues.DelimitedText := FCellText;
|
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;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,8 +145,6 @@ type
|
|||||||
function BestTableName(Data: TDBQuery): String;
|
function BestTableName(Data: TDBQuery): String;
|
||||||
function urlencode(url: String): String;
|
function urlencode(url: String): String;
|
||||||
procedure StreamWrite(S: TStream; Text: 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 _GetFileSize(Filename: String): Int64;
|
||||||
function MakeInt( Str: String ) : Int64;
|
function MakeInt( Str: String ) : Int64;
|
||||||
function MakeFloat( Str: String ): Extended;
|
function MakeFloat( Str: String ): Extended;
|
||||||
@ -431,46 +429,6 @@ begin
|
|||||||
end;
|
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
|
Return filesize of a given file
|
||||||
@param string Filename
|
@param string Filename
|
||||||
|
Reference in New Issue
Block a user