mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-03 18:01:29 +02:00
SearchResultView: shortcuts and menu for page navigation and expand/collapse. Issue #19954, based on patch from Flávio Etrusco
git-svn-id: trunk@31996 -
This commit is contained in:
parent
5d39026d37
commit
f89932be90
@ -282,6 +282,8 @@ resourcestring
|
||||
lisCopyItemToClipboard = 'Copy item to clipboard';
|
||||
lisCopySelectedItemToClipboard = 'Copy selected items to clipboard';
|
||||
lisCopyAllItemsToClipboard = 'Copy all items to clipboard';
|
||||
lisExpandAll = 'Expand All (*)';
|
||||
lisCollapseAll = 'Collapse All (/)';
|
||||
lisSaveAllMessagesToFile = 'Save all messages to file';
|
||||
lisMenuViewSearchResults = 'Search Results';
|
||||
lisMenuViewAnchorEditor = 'Anchor Editor';
|
||||
|
@ -12,7 +12,7 @@ object SearchResultsView: TSearchResultsView
|
||||
OnCreate = Form1Create
|
||||
OnKeyDown = FormKeyDown
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '0.9.29'
|
||||
LCLVersion = '0.9.31'
|
||||
object ResultsNoteBook: TPageControl
|
||||
Left = 0
|
||||
Height = 248
|
||||
@ -21,6 +21,7 @@ object SearchResultsView: TSearchResultsView
|
||||
Align = alClient
|
||||
MultiLine = True
|
||||
TabOrder = 0
|
||||
OnChange = ResultsNoteBookPageChanged
|
||||
OnCloseTabClicked = ResultsNoteBookClosetabclicked
|
||||
OnMouseDown = ResultsNoteBookMouseDown
|
||||
OnPageChanged = ResultsNoteBookPageChanged
|
||||
@ -52,33 +53,33 @@ object SearchResultsView: TSearchResultsView
|
||||
object ToolButton3: TToolButton
|
||||
Left = 47
|
||||
Top = 2
|
||||
Width = 8
|
||||
Width = 10
|
||||
Caption = 'ToolButton3'
|
||||
Style = tbsSeparator
|
||||
end
|
||||
object FilterButton: TToolButton
|
||||
Left = 55
|
||||
Left = 57
|
||||
Top = 2
|
||||
Caption = 'FilterButton'
|
||||
ImageIndex = 2
|
||||
OnClick = FilterButtonClick
|
||||
end
|
||||
object ForwardSearchButton: TToolButton
|
||||
Left = 78
|
||||
Left = 80
|
||||
Top = 2
|
||||
Caption = 'ForwardSearchButton'
|
||||
ImageIndex = 3
|
||||
OnClick = ForwardSearchButtonClick
|
||||
end
|
||||
object ResetResultsButton: TToolButton
|
||||
Left = 449
|
||||
Left = 451
|
||||
Top = 2
|
||||
Caption = 'ResetResultsButton'
|
||||
ImageIndex = 4
|
||||
OnClick = ResetResultsButtonClick
|
||||
end
|
||||
object SearchInListEdit: TEdit
|
||||
Left = 101
|
||||
Left = 103
|
||||
Height = 23
|
||||
Top = 2
|
||||
Width = 348
|
||||
@ -272,6 +273,17 @@ object SearchResultsView: TSearchResultsView
|
||||
Caption = 'Copy Selected'
|
||||
OnClick = mniCopySelectedClick
|
||||
end
|
||||
object MenuItem1: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
object mniExpandAll: TMenuItem
|
||||
Caption = 'Expand All'
|
||||
OnClick = mniExpandAllClick
|
||||
end
|
||||
object mniCollapseAll: TMenuItem
|
||||
Caption = 'Collapse All'
|
||||
OnClick = mniCollapseAllClick
|
||||
end
|
||||
end
|
||||
object ActionList: TActionList
|
||||
Images = ImageList
|
||||
@ -282,5 +294,13 @@ object SearchResultsView: TSearchResultsView
|
||||
OnExecute = ClosePageButtonClick
|
||||
ShortCut = 16499
|
||||
end
|
||||
object actNextPage: TAction
|
||||
OnExecute = actNextPageExecute
|
||||
ShortCut = 16393
|
||||
end
|
||||
object actPrevPage: TAction
|
||||
OnExecute = actPrevPageExecute
|
||||
ShortCut = 24585
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -130,7 +130,12 @@ type
|
||||
|
||||
TSearchResultsView = class(TForm)
|
||||
actClosePage: TAction;
|
||||
actNextPage: TAction;
|
||||
actPrevPage: TAction;
|
||||
ActionList: TActionList;
|
||||
MenuItem1: TMenuItem;
|
||||
mniCollapseAll: TMenuItem;
|
||||
mniExpandAll: TMenuItem;
|
||||
mniCopySelected: TMenuItem;
|
||||
mniCopyAll: TMenuItem;
|
||||
mniCopyItem: TMenuItem;
|
||||
@ -145,6 +150,8 @@ type
|
||||
ClosePageButton: TToolButton;
|
||||
ForwardSearchButton: TToolButton;
|
||||
ResetResultsButton: TToolButton;
|
||||
procedure actNextPageExecute(Sender: TObject);
|
||||
procedure actPrevPageExecute(Sender: TObject);
|
||||
procedure ClosePageButtonClick(Sender: TObject);
|
||||
procedure Form1Create(Sender: TObject);
|
||||
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
@ -152,6 +159,8 @@ type
|
||||
procedure mniCopyAllClick(Sender: TObject);
|
||||
procedure mniCopyItemClick(Sender: TObject);
|
||||
procedure mniCopySelectedClick(Sender: TObject);
|
||||
procedure mniExpandAllClick(Sender: TObject);
|
||||
procedure mniCollapseAllClick(Sender: TObject);
|
||||
procedure ResultsNoteBookMouseDown(Sender: TObject; Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: Integer);
|
||||
procedure TreeViewKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||
@ -165,6 +174,7 @@ type
|
||||
X, Y: Integer);
|
||||
Procedure LazTVMouseWheel(Sender: TObject; Shift: TShiftState;
|
||||
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
|
||||
procedure TreeViewKeyPress(Sender: TObject; var Key: char);
|
||||
procedure edSearchInListChange(Sender: TObject );
|
||||
procedure ResultsNoteBookPageChanged (Sender: TObject );
|
||||
procedure ForwardSearchButtonClick(Sender: TObject );
|
||||
@ -311,6 +321,8 @@ begin
|
||||
mniCopyItem.Caption := lisCopyItemToClipboard;
|
||||
mniCopySelected.Caption := lisCopySelectedItemToClipboard;
|
||||
mniCopyAll.Caption := lisCopyAllItemsToClipboard;
|
||||
mniExpandAll.Caption := lisExpandAll;
|
||||
mniCollapseAll.Caption := lisCollapseAll;
|
||||
end;//Create
|
||||
|
||||
procedure TSearchResultsView.FormClose(Sender: TObject;
|
||||
@ -368,6 +380,26 @@ begin
|
||||
Clipboard.AsText := GetTreeSelectedItemsAsText(popList.PopupComponent as TCustomTreeView);
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.mniExpandAllClick(Sender: TObject);
|
||||
var
|
||||
CurrentTV: TLazSearchResultTV;
|
||||
Key: Char = '*';
|
||||
begin
|
||||
CurrentTV := GetTreeView(ResultsNoteBook.PageIndex);
|
||||
if Assigned(CurrentTV) then
|
||||
TreeViewKeyPress(CurrentTV, Key);
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.mniCollapseAllClick(Sender: TObject);
|
||||
var
|
||||
CurrentTV: TLazSearchResultTV;
|
||||
Key: Char = '/';
|
||||
begin
|
||||
CurrentTV := GetTreeView(ResultsNoteBook.PageIndex);
|
||||
if Assigned(CurrentTV) then
|
||||
TreeViewKeyPress(CurrentTV, Key);
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.ResultsNoteBookMouseDown(Sender: TObject; Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: Integer);
|
||||
var
|
||||
@ -385,6 +417,16 @@ begin
|
||||
ClosePage(ResultsNoteBook.PageIndex);
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.actNextPageExecute(Sender: TObject);
|
||||
begin
|
||||
ResultsNoteBook.SelectNextPage(True);
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.actPrevPageExecute(Sender: TObject);
|
||||
begin
|
||||
ResultsNoteBook.SelectNextPage(False);
|
||||
end;
|
||||
|
||||
{Keeps track of the Index of the Item the mouse is over, Sets ShowHint to true
|
||||
if the Item length is longer than the TreeView client width.}
|
||||
procedure TSearchResultsView.LazTVMousemove(Sender: TObject; Shift: TShiftState;
|
||||
@ -418,6 +460,29 @@ begin
|
||||
Handled:= false;
|
||||
end;//LazTVMouseWheel
|
||||
|
||||
procedure TSearchResultsView.TreeViewKeyPress(Sender: TObject; var Key: char);
|
||||
var
|
||||
i: Integer;
|
||||
Tree: TLazSearchResultTV;
|
||||
Node: TTreeNode;
|
||||
Collapse: Boolean;
|
||||
begin
|
||||
if Key in ['/', '*'] then
|
||||
begin
|
||||
Collapse := Key = '/';
|
||||
Tree := (Sender as TLazSearchResultTV);
|
||||
for i := Tree.Items.TopLvlCount -1 downto 0 do
|
||||
begin
|
||||
Node := Tree.Items.TopLvlItems[i];
|
||||
if Collapse then
|
||||
Node.Collapse(False)
|
||||
else
|
||||
Node.Expand(False);
|
||||
end;
|
||||
Key := #0;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.edSearchInListChange (Sender: TObject );
|
||||
var CurrentTV: TLazSearchResultTV;
|
||||
begin
|
||||
@ -872,6 +937,7 @@ begin
|
||||
OnMouseMove:= @LazTVMousemove;
|
||||
OnMouseWheel:= @LazTVMouseWheel;
|
||||
OnMouseDown:=@TreeViewMouseDown;
|
||||
OnKeyPress:=@TreeViewKeyPress;
|
||||
ShowHint:= true;
|
||||
RowSelect := True; // we are using custom draw
|
||||
Options := Options + [tvoAllowMultiselect] - [tvoThemedDraw];
|
||||
|
Loading…
Reference in New Issue
Block a user