mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 11:17:57 +08:00
Convert ListCommandStats from TSortListView to VirtualTree.
- Make OnInitNode a general procedure by detecting which list was the Sender. - Add recommended OnFreeNode procedure for all VT's.
This commit is contained in:
@ -139,7 +139,7 @@ object MDIChild: TMDIChild
|
|||||||
OnGetImageIndex = vstGetImageIndex
|
OnGetImageIndex = vstGetImageIndex
|
||||||
OnGetNodeDataSize = vstGetNodeDataSize
|
OnGetNodeDataSize = vstGetNodeDataSize
|
||||||
OnHeaderClick = vstHeaderClick
|
OnHeaderClick = vstHeaderClick
|
||||||
OnInitNode = ListVariablesInitNode
|
OnInitNode = vstInitNode
|
||||||
Columns = <
|
Columns = <
|
||||||
item
|
item
|
||||||
Options = [coAllowClick, coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coVisible]
|
Options = [coAllowClick, coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coVisible]
|
||||||
@ -216,47 +216,71 @@ object MDIChild: TMDIChild
|
|||||||
object tabCommandStats: TTabSheet
|
object tabCommandStats: TTabSheet
|
||||||
Caption = 'Command-Statistics'
|
Caption = 'Command-Statistics'
|
||||||
ImageIndex = 2
|
ImageIndex = 2
|
||||||
object ListCommandStats: TSortListView
|
object ListCommandStats: TVirtualStringTree
|
||||||
Left = 0
|
Left = 0
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 488
|
Width = 488
|
||||||
Height = 175
|
Height = 175
|
||||||
Align = alClient
|
Align = alClient
|
||||||
|
Header.AutoSizeIndex = 4
|
||||||
|
Header.Font.Charset = DEFAULT_CHARSET
|
||||||
|
Header.Font.Color = clWindowText
|
||||||
|
Header.Font.Height = -11
|
||||||
|
Header.Font.Name = 'Tahoma'
|
||||||
|
Header.Font.Style = []
|
||||||
|
Header.Height = 20
|
||||||
|
Header.Options = [hoAutoResize, hoColumnResize, hoDblClickResize, hoDrag, hoShowSortGlyphs, hoVisible]
|
||||||
|
Header.SortColumn = 1
|
||||||
|
Header.SortDirection = sdDescending
|
||||||
|
Header.Style = hsFlatButtons
|
||||||
|
Images = MainForm.ImageList1
|
||||||
|
IncrementalSearch = isInitializedOnly
|
||||||
|
PopupMenu = popupHost
|
||||||
|
TabOrder = 0
|
||||||
|
TreeOptions.MiscOptions = [toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning]
|
||||||
|
TreeOptions.PaintOptions = [toShowButtons, toShowDropmark, toShowHorzGridLines, toShowVertGridLines, toThemeAware, toUseBlendedImages]
|
||||||
|
TreeOptions.SelectionOptions = [toFullRowSelect]
|
||||||
|
OnCompareNodes = vstCompareNodes
|
||||||
|
OnFreeNode = vstFreeNode
|
||||||
|
OnGetText = vstGetText
|
||||||
|
OnGetImageIndex = vstGetImageIndex
|
||||||
|
OnGetNodeDataSize = vstGetNodeDataSize
|
||||||
|
OnHeaderClick = vstHeaderClick
|
||||||
|
OnInitNode = vstInitNode
|
||||||
Columns = <
|
Columns = <
|
||||||
item
|
item
|
||||||
Caption = 'Command-type'
|
Options = [coAllowClick, coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coVisible]
|
||||||
|
Position = 0
|
||||||
Width = 120
|
Width = 120
|
||||||
|
WideText = 'Command-type'
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
Caption = 'Total count'
|
Options = [coAllowClick, coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coVisible]
|
||||||
|
Position = 1
|
||||||
Width = 100
|
Width = 100
|
||||||
|
WideText = 'Total count'
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
Caption = 'Average per hour'
|
Options = [coAllowClick, coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coVisible]
|
||||||
|
Position = 2
|
||||||
Width = 100
|
Width = 100
|
||||||
|
WideText = 'Average per hour'
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
Caption = 'Average per second'
|
Options = [coAllowClick, coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coVisible]
|
||||||
|
Position = 3
|
||||||
Width = 100
|
Width = 100
|
||||||
|
WideText = 'Average per second'
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
Alignment = taRightJustify
|
Options = [coAllowClick, coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coVisible]
|
||||||
Caption = 'Percentage'
|
Position = 4
|
||||||
Width = 67
|
Width = 64
|
||||||
|
WideText = 'Percentage'
|
||||||
end>
|
end>
|
||||||
GridLines = True
|
|
||||||
ReadOnly = True
|
|
||||||
RowSelect = True
|
|
||||||
PopupMenu = popupHost
|
|
||||||
SmallImages = MainForm.ImageList1
|
|
||||||
SortType = stBoth
|
|
||||||
TabOrder = 0
|
|
||||||
ViewStyle = vsReport
|
|
||||||
ImageIndexSortAsc = 95
|
|
||||||
ImageIndexSortDesc = 94
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -266,7 +266,7 @@ type
|
|||||||
ManageIndexes1: TMenuItem;
|
ManageIndexes1: TMenuItem;
|
||||||
btnTableManageIndexes: TToolButton;
|
btnTableManageIndexes: TToolButton;
|
||||||
tabCommandStats: TTabSheet;
|
tabCommandStats: TTabSheet;
|
||||||
ListCommandStats: TSortListView;
|
ListCommandStats: TVirtualStringTree;
|
||||||
CheckBoxDataSearch: TCheckBox;
|
CheckBoxDataSearch: TCheckBox;
|
||||||
QF13: TMenuItem;
|
QF13: TMenuItem;
|
||||||
QF14: TMenuItem;
|
QF14: TMenuItem;
|
||||||
@ -499,8 +499,9 @@ type
|
|||||||
procedure RunAsyncPost(ds: TDeferDataSet);
|
procedure RunAsyncPost(ds: TDeferDataSet);
|
||||||
procedure vstGetNodeDataSize(Sender: TBaseVirtualTree; var
|
procedure vstGetNodeDataSize(Sender: TBaseVirtualTree; var
|
||||||
NodeDataSize: Integer);
|
NodeDataSize: Integer);
|
||||||
procedure ListVariablesInitNode(Sender: TBaseVirtualTree; ParentNode, Node:
|
procedure vstInitNode(Sender: TBaseVirtualTree; ParentNode, Node:
|
||||||
PVirtualNode; var InitialStates: TVirtualNodeInitStates);
|
PVirtualNode; var InitialStates: TVirtualNodeInitStates);
|
||||||
|
procedure vstFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
|
||||||
procedure vstGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
|
procedure vstGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
|
||||||
Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString);
|
Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString);
|
||||||
procedure vstGetImageIndex(Sender: TBaseVirtualTree; Node:
|
procedure vstGetImageIndex(Sender: TBaseVirtualTree; Node:
|
||||||
@ -529,7 +530,8 @@ type
|
|||||||
UserQueryFired : Boolean;
|
UserQueryFired : Boolean;
|
||||||
CachedTableLists : TStringList;
|
CachedTableLists : TStringList;
|
||||||
QueryHelpersSelectedItems : Array[0..3] of Integer;
|
QueryHelpersSelectedItems : Array[0..3] of Integer;
|
||||||
VTRowDataListVariables : Array of TVTreeData;
|
VTRowDataListVariables,
|
||||||
|
VTRowDataListCommandStats : Array of TVTreeData;
|
||||||
|
|
||||||
function GetQueryRunning: Boolean;
|
function GetQueryRunning: Boolean;
|
||||||
procedure SetQueryRunning(running: Boolean);
|
procedure SetQueryRunning(running: Boolean);
|
||||||
@ -2546,30 +2548,32 @@ procedure TMDIChild.ShowVariablesAndProcesses(Sender: TObject);
|
|||||||
|
|
||||||
procedure addLVitem( caption: String; commandCount: Int64; totalCount: Int64 );
|
procedure addLVitem( caption: String; commandCount: Int64; totalCount: Int64 );
|
||||||
var
|
var
|
||||||
n : TListItem;
|
i : Integer;
|
||||||
tmpval : Double;
|
tmpval : Double;
|
||||||
begin
|
begin
|
||||||
n := ListCommandStats.Items.Add;
|
SetLength( VTRowDataListCommandStats, Length(VTRowDataListCommandStats)+1 );
|
||||||
n.ImageIndex := 86;
|
i := Length(VTRowDataListCommandStats)-1;
|
||||||
|
VTRowDataListCommandStats[i].ImageIndex := 86;
|
||||||
|
VTRowDataListCommandStats[i].Captions := TStringList.Create;
|
||||||
caption := Copy( caption, 5, Length(caption) );
|
caption := Copy( caption, 5, Length(caption) );
|
||||||
caption := StringReplace( caption, '_', ' ', [rfReplaceAll] );
|
caption := StringReplace( caption, '_', ' ', [rfReplaceAll] );
|
||||||
n.Caption := caption;
|
VTRowDataListCommandStats[i].Captions.Add( caption );
|
||||||
// Total Frequency
|
// Total Frequency
|
||||||
n.Subitems.Add( FormatNumber( commandCount ) );
|
VTRowDataListCommandStats[i].Captions.Add( FormatNumber( commandCount ) );
|
||||||
// Average per hour
|
// Average per hour
|
||||||
uptime := max(uptime, 1);
|
uptime := max(uptime, 1);
|
||||||
tmpval := commandCount / ( uptime / 60 / 60 );
|
tmpval := commandCount / ( uptime / 60 / 60 );
|
||||||
n.Subitems.Add( FormatNumber( tmpval, 1 ) );
|
VTRowDataListCommandStats[i].Captions.Add( FormatNumber( tmpval, 1 ) );
|
||||||
// Average per second
|
// Average per second
|
||||||
tmpval := commandCount / uptime;
|
tmpval := commandCount / uptime;
|
||||||
n.Subitems.Add( FormatNumber( tmpval, 1 ) );
|
VTRowDataListCommandStats[i].Captions.Add( FormatNumber( tmpval, 1 ) );
|
||||||
// Percentage. Take care of division by zero errors and Int64's
|
// Percentage. Take care of division by zero errors and Int64's
|
||||||
if commandCount < 1 then
|
if commandCount < 1 then
|
||||||
commandCount := 1;
|
commandCount := 1;
|
||||||
if totalCount < 1 then
|
if totalCount < 1 then
|
||||||
totalCount := 1;
|
totalCount := 1;
|
||||||
tmpval := 100 / totalCount * commandCount;
|
tmpval := 100 / totalCount * commandCount;
|
||||||
n.Subitems.Add( FormatNumber( tmpval, 1 ) + ' %' );
|
VTRowDataListCommandStats[i].Captions.Add( FormatNumber( tmpval, 1 ) + ' %' );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -2619,12 +2623,12 @@ begin
|
|||||||
ListVariables.ReinitNode(nil, true);
|
ListVariables.ReinitNode(nil, true);
|
||||||
// Manually invoke sorting
|
// Manually invoke sorting
|
||||||
ListVariables.SortTree( ListVariables.Header.SortColumn, ListVariables.Header.SortDirection );
|
ListVariables.SortTree( ListVariables.Header.SortColumn, ListVariables.Header.SortDirection );
|
||||||
// Display number of listed values on tab
|
// Display number of listed values on tab
|
||||||
tabVariables.Caption := 'Variables (' + IntToStr(ListVariables.RootNodeCount) + ')';
|
tabVariables.Caption := 'Variables (' + IntToStr(ListVariables.RootNodeCount) + ')';
|
||||||
|
|
||||||
// Command-Statistics
|
// Command-Statistics
|
||||||
ListCommandStats.Items.BeginUpdate;
|
ListCommandStats.BeginUpdate;
|
||||||
ListCommandStats.Items.Clear;
|
SetLength( VTRowDataListCommandStats, 0 );
|
||||||
addLVitem( ' All commands', questions, questions );
|
addLVitem( ' All commands', questions, questions );
|
||||||
ds.First;
|
ds.First;
|
||||||
for i:=1 to ds.RecordCount do
|
for i:=1 to ds.RecordCount do
|
||||||
@ -2635,10 +2639,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
ds.Next;
|
ds.Next;
|
||||||
end;
|
end;
|
||||||
ListCommandStats.Items.EndUpdate;
|
|
||||||
// Sort 2nd column descending
|
// Tell VirtualTree the number of nodes it will display
|
||||||
ListCommandStats.ColClick( ListCommandStats.Columns[1] );
|
ListCommandStats.RootNodeCount := Length(VTRowDataListCommandStats);
|
||||||
ListCommandStats.ColClick( ListCommandStats.Columns[1] );
|
ListCommandStats.ReinitNode(nil, true);
|
||||||
|
// Manually invoke sorting
|
||||||
|
ListCommandStats.SortTree( ListCommandStats.Header.SortColumn, ListCommandStats.Header.SortDirection );
|
||||||
|
ListCommandStats.EndUpdate;
|
||||||
|
|
||||||
TimerHostUptime.Enabled := true;
|
TimerHostUptime.Enabled := true;
|
||||||
TimerHostUptimeTimer(self);
|
TimerHostUptimeTimer(self);
|
||||||
@ -5899,19 +5906,43 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
{**
|
{**
|
||||||
ListVariables initializes its nodes by calling the following procedure
|
Various lists initialize their nodes by calling the following procedure
|
||||||
once per node
|
once per node
|
||||||
}
|
}
|
||||||
procedure TMDIChild.ListVariablesInitNode(Sender: TBaseVirtualTree; ParentNode,
|
procedure TMDIChild.vstInitNode(Sender: TBaseVirtualTree; ParentNode,
|
||||||
Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
|
Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
|
||||||
var
|
var
|
||||||
NodeData : PVTreeData;
|
NodeData : PVTreeData;
|
||||||
begin
|
begin
|
||||||
// Get the pointer to the node data
|
// Get the pointer to the node data
|
||||||
NodeData := ListVariables.GetNodeData(Node);
|
NodeData := Sender.GetNodeData(Node);
|
||||||
// Bind data to node
|
// Bind data to node
|
||||||
NodeData.Captions := VTRowDataListVariables[Node.Index].Captions;
|
if Sender = ListVariables then
|
||||||
NodeData.ImageIndex := VTRowDataListVariables[Node.Index].ImageIndex;
|
begin
|
||||||
|
NodeData.Captions := VTRowDataListVariables[Node.Index].Captions;
|
||||||
|
NodeData.ImageIndex := VTRowDataListVariables[Node.Index].ImageIndex;
|
||||||
|
end
|
||||||
|
else if Sender = ListCommandStats then
|
||||||
|
begin
|
||||||
|
NodeData.Captions := VTRowDataListCommandStats[Node.Index].Captions;
|
||||||
|
NodeData.ImageIndex := VTRowDataListCommandStats[Node.Index].ImageIndex;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{**
|
||||||
|
Free data of a node
|
||||||
|
}
|
||||||
|
procedure TMDIChild.vstFreeNode(Sender: TBaseVirtualTree; Node:
|
||||||
|
PVirtualNode);
|
||||||
|
var
|
||||||
|
NodeData : PVTreeData;
|
||||||
|
begin
|
||||||
|
// Get the pointer to the node data
|
||||||
|
NodeData := Sender.GetNodeData(Node);
|
||||||
|
// Free data
|
||||||
|
NodeData.Captions.Free;
|
||||||
|
NodeData.ImageIndex := -1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ begin
|
|||||||
0 : case cwin.PageControlHost.ActivePageIndex of
|
0 : case cwin.PageControlHost.ActivePageIndex of
|
||||||
// 0 : begin list := cwin.ListVariables; title := 'Server-Variables for ' + cwin.Conn.MysqlParams.Host; end;
|
// 0 : begin list := cwin.ListVariables; title := 'Server-Variables for ' + cwin.Conn.MysqlParams.Host; end;
|
||||||
1 : begin list := cwin.ListProcesses; title := 'Processlist for ' + cwin.Conn.MysqlParams.Host; end;
|
1 : begin list := cwin.ListProcesses; title := 'Processlist for ' + cwin.Conn.MysqlParams.Host; end;
|
||||||
2 : begin list := cwin.ListCommandStats; title := 'Command-statistics for ' + cwin.Conn.MysqlParams.Host; end;
|
// 2 : begin list := cwin.ListCommandStats; title := 'Command-statistics for ' + cwin.Conn.MysqlParams.Host; end;
|
||||||
end;
|
end;
|
||||||
1 : begin list := cwin.ListTables; title := 'Tables-List for Database ' + cwin.ActualDatabase; end;
|
1 : begin list := cwin.ListTables; title := 'Tables-List for Database ' + cwin.ActualDatabase; end;
|
||||||
2 : begin list := cwin.ListColumns; title := 'Field-List for ' + cwin.ActualDatabase + '/' + cwin.ActualTable; end;
|
2 : begin list := cwin.ListColumns; title := 'Field-List for ' + cwin.ActualDatabase + '/' + cwin.ActualTable; end;
|
||||||
|
Reference in New Issue
Block a user