Browse Source

Fixed some UI bugs in Explorers.

Ugochukwu Mmaduekwe 7 years ago
parent
commit
51113d4103

+ 17 - 19
src/gui/UFRMAccountExplorer.lfm

@@ -7,16 +7,14 @@ object FRMAccountExplorer: TFRMAccountExplorer
   Caption = 'Accounts Explorer'
   ClientHeight = 451
   ClientWidth = 868
-  FormStyle = fsMDIChild
   Menu = meAccountExplorerMenu
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   Position = poOwnerFormCenter
-  LCLVersion = '1.8.2.0'
   Visible = False
   object Splitter1: TSplitter
     Left = 380
-    Height = 365
+    Height = 385
     Top = 66
     Width = 5
   end
@@ -142,17 +140,17 @@ object FRMAccountExplorer: TFRMAccountExplorer
   end
   object pnlAccounts: TPanel
     Left = 0
-    Height = 365
+    Height = 385
     Top = 66
     Width = 380
     Align = alLeft
     BevelOuter = bvNone
-    ClientHeight = 365
+    ClientHeight = 385
     ClientWidth = 380
     TabOrder = 1
     object dgAccounts: TDrawGrid
       Left = 0
-      Height = 331
+      Height = 351
       Top = 0
       Width = 380
       Align = alClient
@@ -166,7 +164,7 @@ object FRMAccountExplorer: TFRMAccountExplorer
     object pnlAccountsInfo: TPanel
       Left = 0
       Height = 34
-      Top = 331
+      Top = 351
       Width = 380
       Align = alBottom
       BevelOuter = bvNone
@@ -247,22 +245,22 @@ object FRMAccountExplorer: TFRMAccountExplorer
   end
   object pcAccountsOptions: TPageControl
     Left = 385
-    Height = 365
+    Height = 385
     Top = 66
     Width = 483
-    ActivePage = tsMultiSelectAccounts
+    ActivePage = tsAccountOperations
     Align = alClient
-    TabIndex = 1
+    TabIndex = 0
     TabOrder = 2
     object tsAccountOperations: TTabSheet
       Caption = 'Operations of selected Account'
-      ClientHeight = 355
-      ClientWidth = 470
+      ClientHeight = 357
+      ClientWidth = 475
       object dgAccountOperations: TDrawGrid
         Left = 0
-        Height = 355
+        Height = 357
         Top = 0
-        Width = 470
+        Width = 475
         Align = alClient
         ExtendedSelect = False
         TabOrder = 0
@@ -275,12 +273,12 @@ object FRMAccountExplorer: TFRMAccountExplorer
     end
     object tsMultiSelectAccounts: TTabSheet
       Caption = 'Selected accounts for massive operations'
-      ClientHeight = 337
+      ClientHeight = 357
       ClientWidth = 475
       ImageIndex = 1
       object dgSelectedAccounts: TDrawGrid
         Left = 41
-        Height = 280
+        Height = 300
         Top = 31
         Width = 325
         Align = alLeft
@@ -318,7 +316,7 @@ object FRMAccountExplorer: TFRMAccountExplorer
       object pnlSelectedAccountsBottom: TPanel
         Left = 0
         Height = 26
-        Top = 311
+        Top = 331
         Width = 475
         Align = alBottom
         BevelOuter = bvNone
@@ -360,12 +358,12 @@ object FRMAccountExplorer: TFRMAccountExplorer
       end
       object pnlSelectedAccountsLeft: TPanel
         Left = 0
-        Height = 280
+        Height = 300
         Top = 31
         Width = 41
         Align = alLeft
         BevelOuter = bvNone
-        ClientHeight = 280
+        ClientHeight = 300
         ClientWidth = 41
         TabOrder = 3
         object sbSelectedAccountsAdd: TSpeedButton

+ 5 - 3
src/gui/UFRMAccountExplorer.pas

@@ -442,16 +442,18 @@ end;
 {%region Event Handlers: Buttons}
 
 procedure TFRMAccountExplorer.bbChangeKeyNameClick(Sender: TObject);
-var i : Integer;
-  nameString : String;
+var
+  i : Integer;
+  name : String;
 begin
   if (cbMyPrivateKeys.ItemIndex<0) then  exit;
   i := PtrInt(cbMyPrivateKeys.Items.Objects[cbMyPrivateKeys.ItemIndex]);
   if (i<0) Or (i>=TWallet.Keys.Count) then raise Exception.Create('Must select a Key');
   name := TWallet.Keys.Key[i].Name;
-  if InputQuery('Change Key name','Input new name',nameString) then begin
+  if InputQuery('Change Key name','Input new name',name) then begin
     TWallet.Keys.SetName(i,name);
   end;
+  RefreshMyKeysCombo;
 end;
 
 procedure TFRMAccountExplorer.bbAccountsRefreshClick(Sender: TObject);

+ 11 - 1
src/gui/UFRMAccountSelect.lfm

@@ -3,6 +3,7 @@ object FRMAccountSelect: TFRMAccountSelect
   Height = 322
   Top = 308
   Width = 601
+  ActiveControl = cbOnlyForSale
   BorderIcons = [biSystemMenu, biMaximize]
   Caption = 'Accounts'
   ClientHeight = 322
@@ -14,7 +15,7 @@ object FRMAccountSelect: TFRMAccountSelect
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   Position = poOwnerFormCenter
-  LCLVersion = '1.6.4.0'
+  Visible = False
   object pnlAccountsTop: TPanel
     Left = 395
     Height = 282
@@ -242,6 +243,15 @@ object FRMAccountSelect: TFRMAccountSelect
       Caption = '000'
       ParentColor = False
     end
+    object bbTypeStats: TBitBtn
+      Left = 280
+      Height = 30
+      Top = 5
+      Width = 95
+      Caption = 'Type stats'
+      OnClick = bbTypeStatsClick
+      TabOrder = 2
+    end
   end
   object dgAccounts: TDrawGrid
     Left = 0

+ 108 - 1
src/gui/UFRMAccountSelect.pas

@@ -23,7 +23,7 @@ uses
   LCLIntf, LCLType, LMessages,
   Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, UAccounts, Grids, StdCtrls, Buttons, ExtCtrls, UCommon.UI,
-  UWallet, UNode, UGridUtils, UConst, UThread;
+  UWallet, UNode, UGridUtils, UFRMMemoText, UConst, UThread;
 
 const
   CT_AS_MyAccounts = $0001;
@@ -66,6 +66,7 @@ type
   { TFRMAccountSelect }
 
   TFRMAccountSelect = class(TApplicationForm)
+    bbTypeStats: TBitBtn;
     cbAccountsName: TCheckBox;
     ebMinBalance: TEdit;
     ebMaxBalance: TEdit;
@@ -87,6 +88,7 @@ type
     cbMyPrivateKeys: TComboBox;
     cbOnlyForPublicSale: TCheckBox;
     procedure bbSearchClick(Sender: TObject);
+    procedure bbTypeStatsClick(Sender: TObject);
     procedure cbMyAccountsChange(Sender: TObject);
     procedure cbMyAccountsClick(Sender: TObject);
     procedure cbMyPrivateKeysChange(Sender: TObject);
@@ -279,6 +281,111 @@ begin
   SearchFiltered;
 end;
 
+procedure TFRMAccountSelect.bbTypeStatsClick(Sender: TObject);
+Type
+  TAccTypeStats = Record
+    accounts:Integer;
+    balance:Int64;
+  end;
+Const
+  TAccTypeStats_NUL : TAccTypeStats = (accounts:0;balance:0);
+Var i,j,k : Integer;
+  account : TAccount;
+  c : Cardinal;
+  s_0,s_inv : TAccTypeStats;
+  s_5 : Array[0..6] of Array[1..4,0..9] of TAccTypeStats;
+  FRM : TFRMMemoText;
+  sl : TStringList;
+begin
+  c := 0;
+  s_0 := TAccTypeStats_NUL;
+  s_inv := TAccTypeStats_NUL;
+  for i := low(s_5) to high(s_5) do
+    for j := 1 to 4 do
+      for k := 0 to 9 do
+        s_5[i,j,k] := TAccTypeStats_NUL;
+
+
+  while (c<FSafeBox.AccountsCount) do begin
+    account := FSafeBox.Account(c);
+    if (account.account_type=0) then begin
+      inc(s_0.accounts);
+      inc(s_0.balance,account.balance);
+    end else if (account.account_type<10000) then begin
+      inc(s_inv.accounts);
+      inc(s_inv.balance,account.balance);
+    end;
+    k := ((account.account_type MOD 100000) DIV 10000); // k is 0..6 because account.account_type is a word 0..65535
+    if (k<0) or (k>6) then k:=0;
+    for i := 0 to 9 do begin
+      j := ((account.account_type MOD 10000) DIV 1000); // j is 0..9
+      if (j=i) then begin
+        inc(s_5[k][1][j].accounts);
+        inc(s_5[k][1][j].balance,account.balance);
+      end;
+    end;
+    for i := 0 to 9 do begin
+      j := ((account.account_type MOD 1000) DIV 100); // j is 0..9
+      if (j=i) then begin
+        inc(s_5[k][2][j].accounts);
+        inc(s_5[k][2][j].balance,account.balance);
+      end;
+    end;
+    for i := 0 to 9 do begin
+      j := ((account.account_type MOD 100) DIV 10); // j is 0..9
+      if (j=i) then begin
+        inc(s_5[k][3][j].accounts);
+        inc(s_5[k][3][j].balance,account.balance);
+      end;
+    end;
+    for i := 0 to 9 do begin
+      j := ((account.account_type MOD 10) DIV 1); // j is 0..9
+      if (j=i) then begin
+        inc(s_5[k][4][j].accounts);
+        inc(s_5[k][4][j].balance,account.balance);
+      end;
+    end;
+    inc(c);
+  end;
+  sl := TStringList.Create;
+  Try
+    sl.Add('*** Account type stats ***');
+    sl.Add(Format('Current block:%d accounts:%d coins:%s',[FSafeBox.BlocksCount,FSafeBox.AccountsCount,TAccountComp.FormatMoney(FSafeBox.TotalBalance)]));
+    sl.Add('');
+    sl.Add('** Basic stats **');
+    sl.Add(Format('Account type=0 accounts:%d coins:%s',[s_0.accounts,TAccountComp.FormatMoney(s_0.balance)]));
+    sl.Add(Format('Account type [1..9999] accounts:%d coins:%s',[s_inv.accounts,TAccountComp.FormatMoney(s_inv.balance)]));
+    sl.Add('');
+    sl.Add('*** Stats by group ***');
+    for k := 0 to 6 do begin
+      // Note: Account type is a Word [0..65535], so left digit can be only 0..6, deprecating 6 to not fill, result for stats is 0..5
+      sl.Add('');
+      sl.Add(Format('** Group [%d..%d] **',[(k)*10000,((k+1)*10000)-1]));
+      for j := 0 to 9 do begin
+        sl.Add(Format('Account type like %d%d*** accounts:%d coins:%s',[k,j,s_5[k][1][j].accounts,TAccountComp.FormatMoney(s_5[k][1][j].balance)]));
+      end;
+      for j := 0 to 9 do begin
+        sl.Add(Format('Account type like %d*%d** accounts:%d coins:%s',[k,j,s_5[k][2][j].accounts,TAccountComp.FormatMoney(s_5[k][2][j].balance)]));
+      end;
+      for j := 0 to 9 do begin
+        sl.Add(Format('Account type like %d**%d* accounts:%d coins:%s',[k,j,s_5[k][3][j].accounts,TAccountComp.FormatMoney(s_5[k][3][j].balance)]));
+      end;
+      for j := 0 to 9 do begin
+        sl.Add(Format('Account type like %d***%d accounts:%d coins:%s',[k,j,s_5[k][4][j].accounts,TAccountComp.FormatMoney(s_5[k][4][j].balance)]));
+      end;
+    end;
+    FRM := TFRMMemoText.Create(Self);
+    Try
+      FRM.InitData('Account Type Stats',sl.Text);
+      FRM.ShowModal;
+    Finally
+      FRM.Free;
+    End;
+  Finally
+    sl.Free;
+  End;
+end;
+
 procedure TFRMAccountSelect.cbMyAccountsChange(Sender: TObject);
 begin
   SearchFiltered;

+ 3 - 2
src/gui/UFRMBlockExplorer.lfm

@@ -1,8 +1,9 @@
 object FRMBlockExplorer: TFRMBlockExplorer
   Left = 87
-  Height = 444
+  Height = 424
   Top = 135
   Width = 864
+  ActiveControl = ebBlockChainBlockEnd
   Caption = 'Block Explorer'
   ClientHeight = 424
   ClientWidth = 864
@@ -10,7 +11,7 @@ object FRMBlockExplorer: TFRMBlockExplorer
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   Position = poOwnerFormCenter
-  LCLVersion = '1.6.4.0'
+  Visible = False
   object Panel2: TPanel
     Left = 0
     Height = 41

+ 4 - 2
src/gui/UFRMOperationExplorer.lfm

@@ -1,15 +1,17 @@
 object FRMOperationExplorer: TFRMOperationExplorer
   Left = 190
-  Height = 444
+  Height = 424
   Top = 287
   Width = 864
+  ActiveControl = dgOperationsExplorer
   Caption = 'Operations Explorer'
   ClientHeight = 424
   ClientWidth = 864
   Menu = OperationsExplorerMenu
   OnCreate = FormCreate
   OnDestroy = FormDestroy
-  LCLVersion = '1.6.4.0'
+  Position = poOwnerFormCenter
+  Visible = False
   object dgOperationsExplorer: TDrawGrid
     Left = 0
     Height = 383

+ 4 - 2
src/gui/UFRMPendingOperations.lfm

@@ -1,15 +1,17 @@
 object FRMPendingOperations: TFRMPendingOperations
   Left = 156
-  Height = 357
+  Height = 337
   Top = 188
   Width = 860
+  ActiveControl = dgPendingOperations
   Caption = 'Pending Operations'
   ClientHeight = 337
   ClientWidth = 860
   Menu = PendingOperationsMenu
   OnCreate = FormCreate
   OnDestroy = FormDestroy
-  LCLVersion = '1.6.4.0'
+  Position = poOwnerFormCenter
+  Visible = False
   object pnlPendingOperations: TPanel
     Left = 0
     Height = 86