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