LCL: Implement also msSiblingOnly and msVisibleOnly for TTreeView.MultiSelectStyle. Issue #18043, patch from AlexeyT.

git-svn-id: trunk@54188 -
This commit is contained in:
juha 2017-02-19 10:00:13 +00:00
parent 55b51f1788
commit 07e44579a9

View File

@ -2695,11 +2695,46 @@ begin
end; end;
procedure TTreeNodes.MultiSelect(Node: TTreeNode; ClearWholeSelection: Boolean); procedure TTreeNodes.MultiSelect(Node: TTreeNode; ClearWholeSelection: Boolean);
var
bGoNext, bOnlySiblings, bOnlyVisible: Boolean;
//
procedure _TakeNext(var N: TTreeNode);
begin
if bGoNext then
begin
if bOnlySiblings and bOnlyVisible then
N := N.GetNextVisibleSibling
else
if bOnlySiblings and not bOnlyVisible then
N := N.GetNextSibling
else
if not bOnlySiblings and bOnlyVisible then
N := N.GetNextVisible
else
N := N.GetNext;
end
else
begin
if bOnlySiblings and bOnlyVisible then
N := N.GetPrevVisibleSibling
else
if bOnlySiblings and not bOnlyVisible then
N := N.GetPrevSibling
else
if not bOnlySiblings and bOnlyVisible then
N := N.GetPrevVisible
else
N := N.GetPrev;
end;
end;
//
var var
I, FirstNode, LastNode: TTreeNode; I, FirstNode, LastNode: TTreeNode;
GetNext: Boolean;
begin begin
if Owner<>nil then Owner.LockSelectionChangeEvent; if Owner<>nil then Owner.LockSelectionChangeEvent;
bOnlySiblings := Assigned(Owner) and (msSiblingOnly in Owner.MultiSelectStyle);
bOnlyVisible := Assigned(Owner) and (msVisibleOnly in Owner.MultiSelectStyle);
try try
if FStartMultiSelected=nil then if FStartMultiSelected=nil then
begin begin
@ -2717,15 +2752,12 @@ begin
if Assigned(FLastMultiSelected) then if Assigned(FLastMultiSelected) then
begin begin
LastNode := FLastMultiSelected; LastNode := FLastMultiSelected;
GetNext := (FirstNode.Index <= LastNode.Index); bGoNext := (FirstNode.Index <= LastNode.Index);
I := FirstNode; I := FirstNode;
I.MultiSelected:=False; I.MultiSelected:=False;
while (I<>LastNode) do while (I<>LastNode) do
begin begin
if GetNext then _TakeNext(I);
I:=I.GetNextSibling
else
I:=I.GetPrevSibling;
if I=nil then Break; if I=nil then Break;
I.MultiSelected:=False; I.MultiSelected:=False;
end; end;
@ -2735,15 +2767,12 @@ begin
end; end;
//select again //select again
GetNext := (FirstNode.Index <= Node.Index); bGoNext := (FirstNode.Index <= Node.Index);
I := FirstNode; I := FirstNode;
I.Selected:=True; I.Selected:=True;
while (I<>Node) do while (I<>Node) do
begin begin
if GetNext then _TakeNext(I);
I:=I.GetNextSibling
else
I:=I.GetPrevSibling;
if I=nil then Break; if I=nil then Break;
I.Selected:=True; I.Selected:=True;
end; end;