IDE: Use TreeFilterEdit in search results window. Uses node visibility of TreeView component.

git-svn-id: trunk@34660 -
This commit is contained in:
juha 2012-01-08 10:44:13 +00:00
parent 93b8ed2e30
commit 650b93feca
3 changed files with 78 additions and 283 deletions

View File

@ -4596,13 +4596,9 @@ resourcestring
rsFoundButNotListedHere = 'Found, but not listed here: '; rsFoundButNotListedHere = 'Found, but not listed here: ';
rsStartANewSearch = 'Start a new search'; rsStartANewSearch = 'Start a new search';
rsCloseCurrentPage = 'Close current page'; rsCloseCurrentPage = 'Close current page';
rsFilterTheListWithTheCurrentFilterExpression = 'Filter the list with the ' rsFilterTheListWithString = 'Filter the lines in list with a string';
+'current filter expression'; //rsEnterOneOrMorePhrasesThatYouWantToFilter = 'Enter one or more phrases '
rsGoToTheNextItemInTheSearchList = 'Go to the next item in the search list'; // +'that you want to Filter in the list, separated by space, or comma';
rsResetFilter = 'Reset filter';
rsEnterOneOrMorePhrasesThatYouWantToSearchOrFilterIn = 'Enter one or more '
+'phrases that you want to Search or Filter in the list, separated by '
+'space, or comma';
// Application Bundle // Application Bundle
lisABCreationFailed = 'Error occured during Application Bundle creation: '; lisABCreationFailed = 'Error occured during Application Bundle creation: ';

View File

@ -1,7 +1,7 @@
object SearchResultsView: TSearchResultsView object SearchResultsView: TSearchResultsView
Left = 299 Left = 344
Height = 273 Height = 273
Top = 325 Top = 327
Width = 799 Width = 799
BorderStyle = bsSizeToolWin BorderStyle = bsSizeToolWin
Caption = 'SearchResultsView' Caption = 'SearchResultsView'
@ -14,13 +14,15 @@ object SearchResultsView: TSearchResultsView
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '0.9.31' LCLVersion = '0.9.31'
object ResultsNoteBook: TPageControl object ResultsNoteBook: TPageControl
AnchorSideTop.Control = ToolBar
AnchorSideTop.Side = asrBottom
Left = 0 Left = 0
Height = 248 Height = 249
Top = 25 Top = 24
Width = 799 Width = 799
Align = alClient Anchors = [akTop, akLeft, akRight, akBottom]
MultiLine = True MultiLine = True
TabOrder = 0 TabOrder = 1
OnChange = ResultsNoteBookPageChanged OnChange = ResultsNoteBookPageChanged
OnCloseTabClicked = ResultsNoteBookClosetabclicked OnCloseTabClicked = ResultsNoteBookClosetabclicked
OnMouseDown = ResultsNoteBookMouseDown OnMouseDown = ResultsNoteBookMouseDown
@ -28,13 +30,13 @@ object SearchResultsView: TSearchResultsView
end end
object ToolBar: TToolBar object ToolBar: TToolBar
Left = 0 Left = 0
Height = 25 Height = 24
Top = 0 Top = 0
Width = 799 Width = 57
Align = alNone
AutoSize = True AutoSize = True
Caption = 'ToolBar'
Images = ImageList Images = ImageList
TabOrder = 1 TabOrder = 2
object SearchAgainButton: TToolButton object SearchAgainButton: TToolButton
Left = 1 Left = 1
Top = 2 Top = 2
@ -56,39 +58,22 @@ object SearchResultsView: TSearchResultsView
Caption = 'ToolButton3' Caption = 'ToolButton3'
Style = tbsSeparator Style = tbsSeparator
end end
object FilterButton: TToolButton end
Left = 57 object SearchInListEdit: TTreeFilterEdit
Top = 2 AnchorSideLeft.Control = ToolBar
Caption = 'FilterButton' AnchorSideLeft.Side = asrBottom
ImageIndex = 2 AnchorSideTop.Control = ToolBar
OnClick = FilterButtonClick AnchorSideTop.Side = asrCenter
end Left = 63
object ForwardSearchButton: TToolButton Height = 20
Left = 80 Top = 2
Top = 2 Width = 296
Caption = 'ForwardSearchButton' ButtonWidth = 23
ImageIndex = 3 NumGlyphs = 0
OnClick = ForwardSearchButtonClick BorderSpacing.Left = 6
end MaxLength = 0
object ResetResultsButton: TToolButton TabOrder = 0
Left = 451 OnChange = SearchInListChange
Top = 2
Caption = 'ResetResultsButton'
ImageIndex = 4
OnClick = ResetResultsButtonClick
end
object SearchInListEdit: TEdit
Left = 103
Height = 23
Top = 2
Width = 348
BorderSpacing.Around = 6
OnChange = edSearchInListChange
OnKeyDown = SearchInListEditKeyDown
ParentShowHint = False
ShowHint = True
TabOrder = 0
end
end end
object ImageList: TImageList object ImageList: TImageList
left = 33 left = 33

View File

@ -37,10 +37,10 @@ unit SearchResultView;
interface interface
uses uses
Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs, ComCtrls,
ComCtrls, ExtCtrls, StdCtrls, Buttons, LCLType, LCLIntf, Menus, strutils, ExtCtrls, StdCtrls, Buttons, LCLType, LCLIntf, Menus, strutils, IDEWindowIntf,
IDEWindowIntf, IDEOptionDefs, LazarusIDEStrConsts, EnvironmentOpts, IDEOptionDefs, LazarusIDEStrConsts, EnvironmentOpts, InputHistory, IDEProcs,
InputHistory, IDEProcs, Project, MainIntf, Clipbrd, ActnList, IDECommands; Project, MainIntf, Clipbrd, ActnList, IDECommands, TreeFilterEdit;
type type
{ TLazSearchMatchPos } { TLazSearchMatchPos }
@ -95,10 +95,8 @@ type
fSearchObject: TLazSearch; fSearchObject: TLazSearch;
FSkipped: integer; FSkipped: integer;
fUpdateStrings: TStrings; fUpdateStrings: TStrings;
fBackUpStrings: TStrings;
fUpdating: boolean; fUpdating: boolean;
fUpdateCount: integer; fUpdateCount: integer;
fShortenPathNeeded: boolean;
FSearchInListPhrases: string; FSearchInListPhrases: string;
fFiltered: Boolean; fFiltered: Boolean;
procedure SetSkipped(const AValue: integer); procedure SetSkipped(const AValue: integer);
@ -112,10 +110,8 @@ type
procedure ShortenPaths; procedure ShortenPaths;
procedure FreeObjectsTN(tnItems: TTreeNodes); procedure FreeObjectsTN(tnItems: TTreeNodes);
procedure FreeObjects(slItems: TStrings); procedure FreeObjects(slItems: TStrings);
function BeautifyLine(const Filename: string; X, Y: integer; function BeautifyLine(const Filename: string; X, Y: integer; const Line: string): string;
const Line: string): string;
function BeautifyLine(SearchPos: TLazSearchMatchPos): string; function BeautifyLine(SearchPos: TLazSearchMatchPos): string;
property BackUpStrings: TStrings read fBackUpStrings write fBackUpStrings;
property Filtered: Boolean read fFiltered write fFiltered; property Filtered: Boolean read fFiltered write fFiltered;
property SearchInListPhrases: string read FSearchInListPhrases write FSearchInListPhrases; property SearchInListPhrases: string read FSearchInListPhrases write FSearchInListPhrases;
property UpdateItems: TStrings read fUpdateStrings write fUpdateStrings; property UpdateItems: TStrings read fUpdateStrings write fUpdateStrings;
@ -140,16 +136,13 @@ type
mniCopyAll: TMenuItem; mniCopyAll: TMenuItem;
mniCopyItem: TMenuItem; mniCopyItem: TMenuItem;
popList: TPopupMenu; popList: TPopupMenu;
SearchInListEdit: TEdit;
ImageList: TImageList; ImageList: TImageList;
ResultsNoteBook: TPageControl; ResultsNoteBook: TPageControl;
ToolBar: TToolBar; ToolBar: TToolBar;
SearchAgainButton: TToolButton; SearchAgainButton: TToolButton;
ToolButton3: TToolButton; ToolButton3: TToolButton;
FilterButton: TToolButton;
ClosePageButton: TToolButton; ClosePageButton: TToolButton;
ForwardSearchButton: TToolButton; SearchInListEdit: TTreeFilterEdit;
ResetResultsButton: TToolButton;
procedure actNextPageExecute(Sender: TObject); procedure actNextPageExecute(Sender: TObject);
procedure actPrevPageExecute(Sender: TObject); procedure actPrevPageExecute(Sender: TObject);
procedure ClosePageButtonClick(Sender: TObject); procedure ClosePageButtonClick(Sender: TObject);
@ -175,13 +168,8 @@ type
Procedure LazTVMouseWheel(Sender: TObject; Shift: TShiftState; Procedure LazTVMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
procedure TreeViewKeyPress(Sender: TObject; var Key: char); procedure TreeViewKeyPress(Sender: TObject; var Key: char);
procedure edSearchInListChange(Sender: TObject );
procedure ResultsNoteBookPageChanged (Sender: TObject ); procedure ResultsNoteBookPageChanged (Sender: TObject );
procedure ForwardSearchButtonClick(Sender: TObject ); procedure SearchInListChange(Sender: TObject );
procedure ResetResultsButtonClick(Sender: TObject );
procedure SearchInListEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState );
procedure FilterButtonClick (Sender: TObject );
procedure TreeViewMouseDown(Sender: TObject; Button: TMouseButton; procedure TreeViewMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); Shift: TShiftState; X, Y: Integer);
private private
@ -275,7 +263,7 @@ end;
function SearchResultsView: TSearchResultsView; function SearchResultsView: TSearchResultsView;
begin begin
Result := SearchResultsViewSingleton; Result := SearchResultsViewSingleton;
if SearchResultsViewSingleton <> nil then exit; if Result <> nil then exit;
Application.CreateForm(TSearchResultsView, SearchResultsViewSingleton); Application.CreateForm(TSearchResultsView, SearchResultsViewSingleton);
SearchResultsViewSingleton.OnSelectionChanged := OnSearchResultsViewSelectionChanged; SearchResultsViewSingleton.OnSelectionChanged := OnSearchResultsViewSelectionChanged;
Result := SearchResultsViewSingleton; Result := SearchResultsViewSingleton;
@ -299,10 +287,7 @@ begin
SearchAgainButton.Hint:=rsStartANewSearch; SearchAgainButton.Hint:=rsStartANewSearch;
ClosePageButton.Hint := rsCloseCurrentPage; ClosePageButton.Hint := rsCloseCurrentPage;
FilterButton.Hint:=rsFilterTheListWithTheCurrentFilterExpression; SearchInListEdit.Hint:=rsFilterTheListWithString;
ForwardSearchButton.Hint:=rsGoToTheNextItemInTheSearchList;
ResetResultsButton.Hint:=rsResetFilter;
SearchInListEdit.Hint:=rsEnterOneOrMorePhrasesThatYouWantToSearchOrFilterIn;
CloseCommand := IDECommandList.FindIDECommand(ecClose); CloseCommand := IDECommandList.FindIDECommand(ecClose);
if CloseCommand <> nil then if CloseCommand <> nil then
begin begin
@ -431,13 +416,16 @@ end;
if the Item length is longer than the TreeView client width.} if the Item length is longer than the TreeView client width.}
procedure TSearchResultsView.LazTVMousemove(Sender: TObject; Shift: TShiftState; procedure TSearchResultsView.LazTVMousemove(Sender: TObject; Shift: TShiftState;
X, Y: Integer); X, Y: Integer);
var
Node: TTreeNode;
begin begin
if Sender is TLazSearchResultTV then if Sender is TLazSearchResultTV then
begin begin
with Sender as TLazSearchResultTV do with Sender as TLazSearchResultTV do
begin begin
if Assigned(GetNodeAt(X, Y)) then Node := GetNodeAt(X, Y);
fMouseOverIndex:=GetNodeAt(X, Y).Index if Assigned(Node) then
fMouseOverIndex:=Node.Index
else else
fMouseOverIndex:=-1; fMouseOverIndex:=-1;
if (fMouseOverIndex > -1) and (fMouseOverIndex < Items.Count) if (fMouseOverIndex > -1) and (fMouseOverIndex < Items.Count)
@ -451,14 +439,12 @@ end;//LazTVMousemove
{Keep track of the mouse position over the treeview when the wheel is used} {Keep track of the mouse position over the treeview when the wheel is used}
procedure TSearchResultsView.LazTVMouseWheel(Sender: TObject; procedure TSearchResultsView.LazTVMouseWheel(Sender: TObject;
Shift: TShiftState; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint;
WheelDelta: Integer; var Handled: Boolean);
MousePos: TPoint;
var Handled: Boolean);
begin begin
LazTVMouseMove(Sender,Shift,MousePos.X, MousePos.Y); LazTVMouseMove(Sender,Shift,MousePos.X, MousePos.Y);
Handled:= false; Handled:= false;
end;//LazTVMouseWheel end;
procedure TSearchResultsView.TreeViewKeyPress(Sender: TObject; var Key: char); procedure TSearchResultsView.TreeViewKeyPress(Sender: TObject; var Key: char);
var var
@ -483,184 +469,25 @@ begin
end; end;
end; end;
procedure TSearchResultsView.edSearchInListChange (Sender: TObject );
var CurrentTV: TLazSearchResultTV;
begin
CurrentTV := GetTreeView(ResultsNoteBook.PageIndex);
if Assigned(CurrentTV) then
CurrentTV.SearchInListPhrases := SearchInListEdit.Text;
end;
procedure TSearchResultsView.ResultsNoteBookPageChanged (Sender: TObject ); procedure TSearchResultsView.ResultsNoteBookPageChanged (Sender: TObject );
var CurrentTV: TLazSearchResultTV; var
CurrentTV: TLazSearchResultTV;
begin begin
CurrentTV := GetTreeView(ResultsNoteBook.PageIndex); CurrentTV := GetTreeView(ResultsNoteBook.PageIndex);
if Assigned(CurrentTV) then if Assigned(CurrentTV) then begin
SearchInListEdit.Text := CurrentTV.SearchInListPhrases; SearchInListEdit.FilteredTreeview := CurrentTV;
SearchInListEdit.Filter := CurrentTV.SearchInListPhrases;
end;
UpdateToolbar; UpdateToolbar;
end; end;
procedure TSearchResultsView.ForwardSearchButtonClick (Sender: TObject ); procedure TSearchResultsView.SearchInListChange (Sender: TObject );
var CurrentTV: TLazSearchResultTV;
slPhrases: TStrings;
i, j, iCurrentIndex: Integer;
S: string;
begin
CurrentTV := GetTreeView(ResultsNoteBook.PageIndex);
if Assigned(CurrentTV) then
begin
if (Length(SearchInListEdit.Text) = 0) then Exit;//No Search Phrases specified.
if (CurrentTV.Items.Count <= 0) then Exit;
slPhrases := TStringList.Create;
try
if Assigned(CurrentTV.Selected) then
iCurrentIndex := CurrentTV.Selected.Index + 1
else
iCurrentIndex := 0;
if (iCurrentIndex > CurrentTV.Items.Count) then
iCurrentIndex := CurrentTV.Items.Count;
if (iCurrentIndex < 0) then
iCurrentIndex := 0; //Set to 1st list-item if none are selected
//Parse Phrases
Parse_Search_Phrases(slPhrases);
if (slPhrases.Count > 0) then
begin
for i:=iCurrentIndex to CurrentTV.Items.Count-1 do
begin
S := UpperCase(CurrentTV.Items[i].Text);//for case-insensitive search
for j:=0 to slPhrases.Count-1 do
begin
if (Pos(slPhrases[j], S) <> 0) then
begin
CurrentTV.Items[i].Selected:=True;//Set TreeView's itemindex
Exit;//Found what we looking for, exit
end;//End if (Pos(slPhrases[j], CurrentTV.Items[i]) <> 0)
end;//End for-loop j
end;//End for-loop i
end;//End if if (slPhrases.Count > 0)
finally
FreeAndNil(slPhrases);
SearchInListEdit.SetFocus;
end;//End try-finally
end;//End if Assigned(CurrentTV)
end;
procedure TSearchResultsView.ResetResultsButtonClick (Sender: TObject );
var
i: Integer;
CurrentTV: TLazSearchResultTV;
mpMatchPos, mpOrgMatchPos: TLazSearchMatchPos;
begin
CurrentTV := GetTreeView(ResultsNoteBook.PageIndex);
try
if assigned(CurrentTV) and CurrentTV.Filtered then
begin
if (CurrentTV.Items.Count > 0) then
begin
CurrentTV.FreeObjectsTN(CurrentTV.Items);//Free the objects
CurrentTV.Items.Clear;
end;//End if (CurrentTV.Items.Count > 0)
if (CurrentTV.BackUpStrings.Count > 0) then
begin
CurrentTV.Items.BeginUpdate;
for i:=0 to CurrentTV.BackUpStrings.Count-1 do
begin
mpOrgMatchPos := TLazSearchMatchPos(CurrentTV.BackUpStrings.Objects[i]);
if Assigned(mpOrgMatchPos) then
begin
mpMatchPos := TLazSearchMatchPos.Create;
if CopySearchMatchPos(mpOrgMatchPos, mpMatchPos) then
CurrentTV.AddNode(CurrentTV.BackUpStrings[i], mpMatchPos);
end;//End if Assigned(mpOrgMatchPos)
end;//End for-loop i
end;//End if (CurrentTV.BackUpStrings.Count > 0)
CurrentTV.Items.EndUpdate;
CurrentTV.Filtered := False;
end;//End if CurrentTV.Filtered
finally
SearchInListEdit.SetFocus;
end;//End try-finally
end;
procedure TSearchResultsView.SearchInListEditKeyDown (Sender: TObject;
var Key: Word; Shift: TShiftState );
begin
if (Key = VK_RETURN) then
ForwardSearchButtonClick(ForwardSearchButton);
end;
procedure TSearchResultsView.FilterButtonClick (Sender: TObject );
var var
CurrentTV: TLazSearchResultTV; CurrentTV: TLazSearchResultTV;
mpMatchPos, mpOrgMatchPos: TLazSearchMatchPos;
slPhrases: TStrings;
i, j: Integer;
S: string;
begin begin
CurrentTV := GetTreeView(ResultsNoteBook.PageIndex); CurrentTV := GetTreeView(ResultsNoteBook.PageIndex);
if Assigned(CurrentTV) then if Assigned(CurrentTV) then
begin CurrentTV.SearchInListPhrases := SearchInListEdit.Text;
if (Length(SearchInListEdit.Text) = 0) then Exit;//No Filter Phrases specified.
slPhrases := TStringList.Create;
try
//Parse Phrases
Parse_Search_Phrases(slPhrases);
//BackUp Result List
if not (CurrentTV.Filtered or (CurrentTV.BackUpStrings.Count > 0)) then
begin
if (CurrentTV.Items.Count <= 1) then Exit;
for i:=0 to CurrentTV.Items.Count-1 do
begin
mpOrgMatchPos := TLazSearchMatchPos(CurrentTV.Items[i].Data);
if Assigned(mpOrgMatchPos) then
begin
mpMatchPos := TLazSearchMatchPos.Create;
if CopySearchMatchPos(mpOrgMatchPos, mpMatchPos) then
CurrentTV.BackUpStrings.AddObject(CurrentTV.Items[i].Text, mpMatchPos);
end;//End if Assigned(mpOrgMatchPos)
end;//End for-loop i
end;//End if not (CurrentTV.Filtered or (CurrentTV.BackUpStrings.Count > 0))
if (CurrentTV.BackUpStrings.Count <= 0) then Exit;//Empty list
if (CurrentTV.Items.Count > 0) then
begin
CurrentTV.FreeObjectsTN(CurrentTV.Items);//Free the objects
CurrentTV.Items.Clear;//Clear the list
//Clear update items as their objects are freed together with CurrentTV.Items
CurrentTV.UpdateItems.Clear;
end;//End if (CurrentTV.Items.Count > 0)
if (slPhrases.Count > 0) then
begin
CurrentTV.Items.BeginUpdate;
for i:=0 to CurrentTV.BackUpStrings.Count-1 do
begin
S := UpperCase(CurrentTV.BackUpStrings[i]);//for case-insensitive search
for j:=0 to slPhrases.Count-1 do
begin
if (Pos(slPhrases[j], S) <> 0) then
begin
mpOrgMatchPos := TLazSearchMatchPos(CurrentTV.BackUpStrings.Objects[i]);
if Assigned(mpOrgMatchPos) then
begin
mpMatchPos := TLazSearchMatchPos.Create;
if CopySearchMatchPos(mpOrgMatchPos, mpMatchPos) then
CurrentTV.AddNode(CurrentTV.BackUpStrings[i], mpMatchPos);
end;//End if Assigned(mpOrgMatchPos)
end;//End if (Pos(slPhrases[j], S) <> 0)
end;//End for-loop j
end;//End for-loop i
CurrentTV.Items.EndUpdate;
CurrentTV.Filtered := True;
end;//End if if (slPhrases.Count > 0)
finally
FreeAndNil(slPhrases);
SearchInListEdit.SetFocus;
if (CurrentTV.Items.Count > 0) then CurrentTV.Items[0].Selected:=True;//Goto first item
end;//End try-finally
end;//End if Assigned(CurrentTV)
end; end;
procedure TSearchResultsView.TreeViewMouseDown(Sender: TObject; procedure TSearchResultsView.TreeViewMouseDown(Sender: TObject;
@ -749,7 +576,7 @@ begin
end;//if end;//if
end;//AddMatch end;//AddMatch
Procedure TSearchResultsView.BeginUpdate(APageIndex: integer); procedure TSearchResultsView.BeginUpdate(APageIndex: integer);
var var
CurrentTV: TLazSearchResultTV; CurrentTV: TLazSearchResultTV;
begin begin
@ -757,7 +584,7 @@ begin
if Assigned(CurrentTV) then if Assigned(CurrentTV) then
CurrentTV.BeginUpdate; CurrentTV.BeginUpdate;
UpdateToolbar; UpdateToolbar;
end;//BeginUpdate end;
procedure TSearchResultsView.EndUpdate(APageIndex: integer); procedure TSearchResultsView.EndUpdate(APageIndex: integer);
var var
@ -816,7 +643,7 @@ begin
end; end;
{Sets the Items from the treeview on the currently selected page in the TNoteBook} {Sets the Items from the treeview on the currently selected page in the TNoteBook}
procedure TSearchResultsView.SetItems(Index: integer; Value: TStrings); procedure TSearchResultsView.SetItems(Index: Integer; Value: TStrings);
var var
CurrentTV: TLazSearchResultTV; CurrentTV: TLazSearchResultTV;
begin begin
@ -830,9 +657,9 @@ begin
else else
CurrentTV.Items.Assign(Value); CurrentTV.Items.Assign(Value);
CurrentTV.Skipped:=0; CurrentTV.Skipped:=0;
end;//if end;
end//if end;
end;//SetItems end;
function TSearchResultsView.GetItems(Index: integer): TStrings; function TSearchResultsView.GetItems(Index: integer): TStrings;
var var
@ -846,8 +673,8 @@ begin
result:= CurrentTV.UpdateItems result:= CurrentTV.UpdateItems
else else
Result := CurrentTV.ItemsAsStrings; Result := CurrentTV.ItemsAsStrings;
end;//if end;
end;//GetItems end;
procedure TSearchResultsView.SetMaxItems(const AValue: integer); procedure TSearchResultsView.SetMaxItems(const AValue: integer);
begin begin
@ -864,13 +691,10 @@ begin
state := Assigned(CurrentTV) and not CurrentTV.Updating; state := Assigned(CurrentTV) and not CurrentTV.Updating;
SearchAgainButton.Enabled := state; SearchAgainButton.Enabled := state;
ClosePageButton.Enabled := state; ClosePageButton.Enabled := state;
FilterButton.Enabled := state;
ForwardSearchButton.Enabled := state;
ResetResultsButton.Enabled := state;
SearchInListEdit.Enabled := state; SearchInListEdit.Enabled := state;
end; end;
procedure TSearchResultsView.ResultsNoteBookCloseTabclicked(Sender: TObject); procedure TSearchResultsView.ResultsNoteBookClosetabclicked(Sender: TObject);
begin begin
if (Sender is TTabSheet) then if (Sender is TTabSheet) then
ClosePage(TTabSheet(Sender).PageIndex) ClosePage(TTabSheet(Sender).PageIndex)
@ -955,12 +779,13 @@ begin
end; end;
NewTreeView.Skipped:=0; NewTreeView.Skipped:=0;
Result:= Pages[PageIndex]; Result:= Pages[PageIndex];
SearchInListEdit.Clear; SearchInListEdit.Text:='';
SearchInListEdit.Filter:='';
SearchInListEdit.FilteredTreeview := NewTreeView;
end;//with end;//with
end;//AddResult end;//AddResult
procedure TSearchResultsView.LazTVShowHint(Sender: TObject; procedure TSearchResultsView.LazTVShowHint(Sender: TObject; HintInfo: PHintInfo);
HintInfo: PHintInfo);
var var
MatchPos: TLazSearchMatchPos; MatchPos: TLazSearchMatchPos;
HintStr: string; HintStr: string;
@ -1235,7 +1060,6 @@ begin
fUpdating:= false; fUpdating:= false;
fUpdateCount:= 0; fUpdateCount:= 0;
fUpdateStrings:= TStringList.Create; fUpdateStrings:= TStringList.Create;
fBackUpStrings := TStringList.Create;
FSearchInListPhrases := ''; FSearchInListPhrases := '';
fFiltered := False; fFiltered := False;
end;//Create end;//Create
@ -1244,8 +1068,7 @@ Destructor TLazSearchResultTV.Destroy;
begin begin
if Assigned(fSearchObject) then if Assigned(fSearchObject) then
FreeAndNil(fSearchObject); FreeAndNil(fSearchObject);
//if UpdateStrings is empty, //if UpdateStrings is empty, the objects are stored in Items due to filtering
//means the objects are stored in Items due to filtering
//filtering clears UpdateStrings //filtering clears UpdateStrings
if (fUpdateStrings.Count = 0) then if (fUpdateStrings.Count = 0) then
FreeObjectsTN(Items); FreeObjectsTN(Items);
@ -1253,12 +1076,7 @@ begin
begin begin
FreeObjects(fUpdateStrings); FreeObjects(fUpdateStrings);
FreeAndNil(fUpdateStrings); FreeAndNil(fUpdateStrings);
end;//if end;
if Assigned(fBackUpStrings) then
begin
FreeObjects(fBackUpStrings);
FreeAndNil(fBackUpStrings);
end;//End if Assigned(fBackUpStrings)
inherited Destroy; inherited Destroy;
end;//Destroy end;//Destroy
@ -1277,8 +1095,8 @@ begin
s.Free; s.Free;
end; end;
fUpdating:= true; fUpdating:= true;
end;//if end;
end;//BeginUpdate end;
procedure TLazSearchResultTV.EndUpdate; procedure TLazSearchResultTV.EndUpdate;
var var
@ -1315,11 +1133,7 @@ var
ShownText: String; ShownText: String;
FreeSrcList: Boolean; FreeSrcList: Boolean;
begin begin
if fUpdateCount>0 then begin if fUpdateCount>0 then exit;
fShortenPathNeeded:=true;
exit;
end;
fShortenPathNeeded:=false;
if fUpdating then begin if fUpdating then begin
SrcList:=fUpdateStrings; SrcList:=fUpdateStrings;