- Implemented account list sorting (fixes #79)
This commit is contained in:
parent
b1be3a22de
commit
be11f61111
|
@ -15,7 +15,7 @@ object frmAccountControl: TfrmAccountControl
|
|||
OnDestroy = FormDestroy
|
||||
OnShow = FormShow
|
||||
Position = poOwnerFormCenter
|
||||
LCLVersion = '0.9.29'
|
||||
LCLVersion = '0.9.31'
|
||||
object tbMain: TToolBar
|
||||
Left = 0
|
||||
Height = 26
|
||||
|
@ -30,44 +30,44 @@ object frmAccountControl: TfrmAccountControl
|
|||
Top = 2
|
||||
Caption = 'Refresh'
|
||||
ImageIndex = 0
|
||||
OnClick = tbRefreshClick
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
OnClick = tbRefreshClick
|
||||
end
|
||||
object tbAddUser: TToolButton
|
||||
Left = 32
|
||||
Left = 28
|
||||
Hint = 'Add User'
|
||||
Top = 2
|
||||
Caption = 'Add User'
|
||||
ImageIndex = 1
|
||||
OnClick = tbAddUserClick
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
OnClick = tbAddUserClick
|
||||
end
|
||||
object tbEditUser: TToolButton
|
||||
Left = 55
|
||||
Left = 51
|
||||
Hint = 'Edit User'
|
||||
Top = 2
|
||||
Caption = 'Edit User'
|
||||
ImageIndex = 2
|
||||
OnClick = tbEditUserClick
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
OnClick = tbEditUserClick
|
||||
end
|
||||
object tbDeleteUser: TToolButton
|
||||
Left = 78
|
||||
Left = 74
|
||||
Hint = 'Delete User'
|
||||
Top = 2
|
||||
Caption = 'Delete User'
|
||||
ImageIndex = 3
|
||||
OnClick = tbDeleteUserClick
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
OnClick = tbDeleteUserClick
|
||||
end
|
||||
object tbSeparator1: TToolButton
|
||||
Left = 24
|
||||
Top = 2
|
||||
Width = 8
|
||||
Width = 4
|
||||
Caption = 'tbSeparator1'
|
||||
Style = tbsDivider
|
||||
end
|
||||
|
@ -96,19 +96,21 @@ object frmAccountControl: TfrmAccountControl
|
|||
Width = 100
|
||||
end>
|
||||
Header.DefaultHeight = 17
|
||||
Header.Options = [hoColumnResize, hoDrag, hoVisible]
|
||||
Header.Options = [hoColumnResize, hoDrag, hoShowSortGlyphs, hoVisible]
|
||||
Header.ParentFont = True
|
||||
Header.Style = hsFlatButtons
|
||||
Images = ilAccesslevel
|
||||
TabOrder = 1
|
||||
TreeOptions.AutoOptions = [toAutoScrollOnExpand, toAutoTristateTracking, toAutoDeleteMovedNodes]
|
||||
TreeOptions.AutoOptions = [toAutoScrollOnExpand, toAutoSort, toAutoTristateTracking, toAutoDeleteMovedNodes]
|
||||
TreeOptions.MiscOptions = [toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning]
|
||||
TreeOptions.PaintOptions = [toShowButtons, toShowDropmark, toThemeAware, toUseBlendedImages]
|
||||
TreeOptions.SelectionOptions = [toFullRowSelect]
|
||||
OnCompareNodes = vstAccountsCompareNodes
|
||||
OnDblClick = vstAccountsDblClick
|
||||
OnFreeNode = vstAccountsFreeNode
|
||||
OnGetText = vstAccountsGetText
|
||||
OnGetImageIndex = vstAccountsGetImageIndex
|
||||
OnHeaderClick = vstAccountsHeaderClick
|
||||
end
|
||||
object ilToolbar: TImageList
|
||||
left = 144
|
||||
|
@ -245,7 +247,7 @@ object frmAccountControl: TfrmAccountControl
|
|||
}
|
||||
end
|
||||
object ilAccesslevel: TImageList
|
||||
left = 176
|
||||
left = 184
|
||||
Bitmap = {
|
||||
4C69040000001000000010000000000000000000000000000000000000000000
|
||||
0000A3A3A3FFA0A0A0FF9D9D9DFF9A9A9AFF979797FF949494FF000000000000
|
||||
|
|
|
@ -55,6 +55,8 @@ type
|
|||
procedure tbAddUserClick(Sender: TObject);
|
||||
procedure tbDeleteUserClick(Sender: TObject);
|
||||
procedure tbRefreshClick(Sender: TObject);
|
||||
procedure vstAccountsCompareNodes(Sender: TBaseVirtualTree; Node1,
|
||||
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
|
||||
procedure vstAccountsDblClick(Sender: TObject);
|
||||
procedure vstAccountsFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
|
||||
procedure vstAccountsGetImageIndex(Sender: TBaseVirtualTree;
|
||||
|
@ -62,6 +64,8 @@ type
|
|||
var Ghosted: Boolean; var ImageIndex: Integer);
|
||||
procedure vstAccountsGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
|
||||
Column: TColumnIndex; TextType: TVSTTextType; var CellText: String);
|
||||
procedure vstAccountsHeaderClick(Sender: TVTHeader; Column: TColumnIndex;
|
||||
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||
protected
|
||||
procedure OnModifyUserResponse(ABuffer: TEnhancedMemoryStream);
|
||||
procedure OnDeleteUserResponse(ABuffer: TEnhancedMemoryStream);
|
||||
|
@ -244,6 +248,19 @@ begin
|
|||
dmNetwork.Send(TRequestUserListPacket.Create);
|
||||
end;
|
||||
|
||||
procedure TfrmAccountControl.vstAccountsCompareNodes(Sender: TBaseVirtualTree;
|
||||
Node1, Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
|
||||
var
|
||||
accountInfo1, accountInfo2: PAccountInfo;
|
||||
begin
|
||||
accountInfo1 := Sender.GetNodeData(Node1);
|
||||
accountInfo2 := Sender.GetNodeData(Node2);
|
||||
case Column of
|
||||
1: Result := CompareText(accountInfo1^.Username, accountInfo2^.Username);
|
||||
2: Result := Integer(accountInfo1^.AccessLevel) - Integer(accountInfo2^.AccessLevel);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmAccountControl.vstAccountsDblClick(Sender: TObject);
|
||||
begin
|
||||
tbEditUserClick(Sender);
|
||||
|
@ -292,6 +309,26 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmAccountControl.vstAccountsHeaderClick(Sender: TVTHeader;
|
||||
Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||
begin
|
||||
if Column in [1, 2] then
|
||||
begin
|
||||
if Sender.SortColumn <> Column then
|
||||
begin
|
||||
Sender.SortColumn := Column;
|
||||
Sender.SortDirection := sdAscending;
|
||||
end else
|
||||
begin
|
||||
case Sender.SortDirection of
|
||||
sdAscending: Sender.SortDirection := sdDescending;
|
||||
sdDescending: Sender.SortDirection := sdAscending;
|
||||
end;
|
||||
end;
|
||||
Sender.Treeview.SortTree(Sender.SortColumn, Sender.SortDirection);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmAccountControl.OnModifyUserResponse(ABuffer: TEnhancedMemoryStream);
|
||||
var
|
||||
node: PVirtualNode;
|
||||
|
|
Loading…
Reference in New Issue