From 4549725e992422a7fdadbd1b6ac33baa3d07a16e Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Thu, 15 Jan 2009 23:46:58 +0000 Subject: [PATCH] Move filter box in host subtabs to bottom. Use a single one instead of one per tab. Display search results in a label right besides. Enables this filter feature for the command stats tab, where it was not available previously. --- source/main.dfm | 124 ++++++++++++++++-------------------------------- source/main.pas | 74 ++++++++++++++--------------- 2 files changed, 79 insertions(+), 119 deletions(-) diff --git a/source/main.dfm b/source/main.dfm index 44082721..cc9dff83 100644 --- a/source/main.dfm +++ b/source/main.dfm @@ -496,18 +496,19 @@ object MainForm: TMainForm Left = 0 Top = 0 Width = 502 - Height = 300 + Height = 271 ActivePage = tabVariables Align = alClient HotTrack = True TabOrder = 0 + OnChange = editFilterVTChange object tabVariables: TTabSheet Caption = 'Variables' object ListVariables: TVirtualStringTree Left = 0 - Top = 25 + Top = 0 Width = 494 - Height = 247 + Height = 243 Align = alClient DragOperations = [] Header.AutoSizeIndex = 1 @@ -554,38 +555,14 @@ object MainForm: TMainForm WideText = 'Value' end> end - object pnlFilterVariables: TPanel - Left = 0 - Top = 0 - Width = 494 - Height = 25 - Align = alTop - BevelOuter = bvNone - TabOrder = 1 - object lblFilterVariables: TLabel - Left = 1 - Top = 4 - Width = 28 - Height = 13 - Caption = 'Filter:' - end - object editFilterVariables: TEdit - Left = 34 - Top = 1 - Width = 154 - Height = 21 - TabOrder = 0 - OnChange = editFilterVTChange - end - end end object tabStatus: TTabSheet Caption = 'Status' object ListStatus: TVirtualStringTree Left = 0 - Top = 25 + Top = 0 Width = 494 - Height = 247 + Height = 243 Align = alClient DragOperations = [] Header.AutoSizeIndex = 1 @@ -644,37 +621,13 @@ object MainForm: TMainForm WideText = 'Avg per second' end> end - object pnlFilterStatus: TPanel - Left = 0 - Top = 0 - Width = 494 - Height = 25 - Align = alTop - BevelOuter = bvNone - TabOrder = 1 - object lblFilterStatus: TLabel - Left = 1 - Top = 4 - Width = 28 - Height = 13 - Caption = 'Filter:' - end - object editFilterStatus: TEdit - Left = 34 - Top = 1 - Width = 154 - Height = 21 - TabOrder = 0 - OnChange = editFilterVTChange - end - end end object tabProcessList: TTabSheet Caption = 'Process-List' ImageIndex = 1 object Splitter3: TSplitter Left = 0 - Top = 199 + Top = 170 Width = 494 Height = 4 Cursor = crSizeNS @@ -683,9 +636,9 @@ object MainForm: TMainForm end object ListProcesses: TVirtualStringTree Left = 0 - Top = 25 + Top = 0 Width = 494 - Height = 174 + Height = 170 Align = alClient Header.AutoSizeIndex = 7 Header.Font.Charset = DEFAULT_CHARSET @@ -763,7 +716,7 @@ object MainForm: TMainForm end object pnlProcessViewBox: TPanel Left = 0 - Top = 203 + Top = 174 Width = 494 Height = 69 Align = alBottom @@ -806,30 +759,6 @@ object MainForm: TMainForm WordWrap = True end end - object pnlFilterProcesses: TPanel - Left = 0 - Top = 0 - Width = 494 - Height = 25 - Align = alTop - BevelOuter = bvNone - TabOrder = 2 - object lblFilterProcesses: TLabel - Left = 1 - Top = 4 - Width = 28 - Height = 13 - Caption = 'Filter:' - end - object editFilterProcesses: TEdit - Left = 34 - Top = 1 - Width = 154 - Height = 21 - TabOrder = 0 - OnChange = editFilterVTChange - end - end end object tabCommandStats: TTabSheet Caption = 'Command-Statistics' @@ -838,7 +767,7 @@ object MainForm: TMainForm Left = 0 Top = 0 Width = 494 - Height = 272 + Height = 243 Align = alClient Header.AutoSizeIndex = 4 Header.Font.Charset = DEFAULT_CHARSET @@ -905,6 +834,37 @@ object MainForm: TMainForm end end end + object pnlFilterVT: TPanel + Left = 0 + Top = 271 + Width = 502 + Height = 29 + Align = alBottom + BevelOuter = bvNone + TabOrder = 1 + object lblFilterVT: TLabel + Left = 0 + Top = 8 + Width = 28 + Height = 12 + Caption = 'Filter:' + end + object lblFilterVTInfo: TLabel + Left = 203 + Top = 8 + Width = 66 + Height = 13 + Caption = 'lblFilterVTInfo' + end + object editFilterVT: TEdit + Left = 34 + Top = 5 + Width = 154 + Height = 20 + TabOrder = 0 + OnChange = editFilterVTChange + end + end end object tabDatabase: TTabSheet Caption = 'Database' diff --git a/source/main.pas b/source/main.pas index 6856ec46..6da15dd0 100644 --- a/source/main.pas +++ b/source/main.pas @@ -408,15 +408,10 @@ type pnlProcessViewBox: TPanel; pnlProcessView: TPanel; SynMemoProcessView: TSynMemo; - pnlFilterVariables: TPanel; - lblFilterVariables: TLabel; - editFilterVariables: TEdit; - pnlFilterStatus: TPanel; - lblFilterStatus: TLabel; - editFilterStatus: TEdit; - pnlFilterProcesses: TPanel; - lblFilterProcesses: TLabel; - editFilterProcesses: TEdit; + pnlFilterVT: TPanel; + editFilterVT: TEdit; + lblFilterVT: TLabel; + lblFilterVTInfo: TLabel; menuEditVariable: TMenuItem; menuEditView: TMenuItem; Createview2: TMenuItem; @@ -6783,26 +6778,26 @@ var Node : PVirtualNode; NodeData : PVTreeData; VT : TVirtualStringTree; - Edit : TEdit; i : Integer; match : Boolean; search : String; - somefiltered : Boolean; + tab: TTabSheet; + VisibleCount: Cardinal; begin // Find the correct VirtualTree that shall be filtered - if Sender = editFilterVariables then + tab := PageControlHost.ActivePage; + if tab = tabVariables then VT := ListVariables - else if Sender = editFilterStatus then + else if tab = tabStatus then VT := ListStatus - else if Sender = editFilterProcesses then + else if tab = tabProcesslist then VT := ListProcesses else - Raise Exception.Create('editFilterVTChange() called with wrong sender control ('+(Sender as TControl).Name+')' ); - Edit := Sender as TEdit; + VT := ListCommandStats; // Loop through all nodes to adjust their vsVisible state Node := VT.GetFirst; - search := LowerCase( Edit.Text ); - somefiltered := False; + search := LowerCase( editFilterVT.Text ); + VisibleCount := 0; while Assigned(Node) do begin NodeData := VT.GetNodeData(Node); // Don't filter anything if the filter text is empty @@ -6814,24 +6809,30 @@ begin break; end; end; - if match then - Node.States := Node.States + [vsVisible] - else + if match then begin + Node.States := Node.States + [vsVisible]; + inc(VisibleCount); + end else Node.States := Node.States - [vsVisible]; - if (not somefiltered) and (not match) then - somefiltered := True; Node := VT.GetNext(Node); end; // Colorize TEdit with filter string to signalize that some nodes are hidden now - if somefiltered then begin - Edit.Font.Color := clRed; - Edit.Color := clYellow; + if VisibleCount <> VT.RootNodeCount then begin + editFilterVT.Font.Color := clRed; + editFilterVT.Color := clYellow; end else begin - Edit.Font.Color := clWindowText; - Edit.Color := clWindow; + editFilterVT.Font.Color := clWindowText; + editFilterVT.Color := clWindow; end; + if search <> '' then begin + lblFilterVTInfo.Caption := IntToStr(VisibleCount)+' out of '+IntToStr(VT.RootNodeCount)+' matching. ' + + IntToStr(VT.RootNodeCount - VisibleCount) + ' hidden.'; + end else + lblFilterVTInfo.Caption := ''; + // Needs a refresh to apply visible states VT.Refresh; + VT.UpdateScrollBars(True); end; @@ -8553,9 +8554,8 @@ begin vt.RootNodeCount := Length(VTRowDataListVariables); vt.SortTree(vt.Header.SortColumn, vt.Header.SortDirection); vt.Tag := VTREE_LOADED; - // Apply filter - if editFilterVariables.Text <> '' then - editFilterVTChange(editFilterVariables); + // Apply or reset filter + editFilterVTChange(Sender); // Display number of listed values on tab tabVariables.Caption := 'Variables (' + IntToStr(vt.RootNodeCount) + ')'; Screen.Cursor := crDefault; @@ -8622,9 +8622,8 @@ begin vt.RootNodeCount := Length(VTRowDataListStatus); vt.SortTree(vt.Header.SortColumn, vt.Header.SortDirection); vt.Tag := VTREE_LOADED; - // Apply filter - if editFilterStatus.Text <> '' then - editFilterVTChange(editFilterStatus); + // Apply or reset filter + editFilterVTChange(Sender); // Display number of listed values on tab tabStatus.Caption := 'Status (' + IntToStr(vt.RootNodeCount) + ')'; Screen.Cursor := crDefault; @@ -8666,9 +8665,8 @@ begin vt.RootNodeCount := Length(VTRowDataListProcesses); vt.SortTree(vt.Header.SortColumn, vt.Header.SortDirection); vt.Tag := VTREE_LOADED; - // Apply filter - if editFilterProcesses.Text <> '' then - editFilterVTChange(editFilterProcesses); + // Apply or reset filter + editFilterVTChange(Sender); // Display number of listed values on tab tabProcessList.Caption := 'Process-List (' + IntToStr(vt.RootNodeCount) + ')'; except @@ -8737,6 +8735,8 @@ begin vt.RootNodeCount := Length(VTRowDataListCommandStats); vt.SortTree(vt.Header.SortColumn, vt.Header.SortDirection); vt.Tag := VTREE_LOADED; + // Apply or reset filter + editFilterVTChange(Sender); // Display number of listed values on tab tabCommandStats.Caption := 'Command-Statistics (' + IntToStr(vt.RootNodeCount) + ')'; Screen.Cursor := crDefault;