Browse Source

GUI: show pending balance in wallet accounts

Herman Schoenfeld 7 years ago
parent
commit
5570397498
4 changed files with 19 additions and 9 deletions
  1. 5 2
      src/core.utils/UDataSources.pas
  2. 1 0
      src/gui/UCTRLWallet.lfm
  3. 2 1
      src/gui/UCTRLWallet.pas
  4. 11 6
      src/gui/UCellRenderers.pas

+ 5 - 2
src/core.utils/UDataSources.pas

@@ -140,7 +140,8 @@ begin
     TDataColumn.From('Price'),
     TDataColumn.From('PriceDecimal'),
     TDataColumn.From('LockedUntil'),
-    TDataColumn.From('NumberOfOperations')
+    TDataColumn.From('NOperation'),
+    TDataColumn.From('LastUpdatedBlock')
   );
 end;
 
@@ -172,8 +173,10 @@ begin
     Result := TAccountComp.FormatMoneyDecimal(AItem.accountInfo.price)
   else if ABindingName = 'LockedUntil' then
     Result := AItem.accountInfo.locked_until_block
-  else if ABindingName = 'NumberOfOperations' then
+  else if ABindingName = 'NOperation' then
     Result := AItem.n_operation
+  else if ABindingName = 'LastUpdatedBlock' then
+    Result := AItem.updated_block
   else
     raise Exception.Create(Format('Field not found "%s"', [ABindingName]));
 end;

+ 1 - 0
src/gui/UCTRLWallet.lfm

@@ -10,6 +10,7 @@ object CTRLWallet: TCTRLWallet
   ClientWidth = 1151
   OnCreate = FormCreate
   OnResize = FormResize
+  LCLVersion = '1.8.2.0'
   Visible = False
   object PairSplitter1: TPairSplitter
     Left = 0

+ 2 - 1
src/gui/UCTRLWallet.pas

@@ -127,6 +127,7 @@ begin
 
   // fields
   FAccountsDataSource := TMyAccountsDataSource.Create(Self);
+  FAccountsDataSource.IncludePending := true;
   FAccountsDataSource.BalancePointer := @FBalance;
   FOperationsDataSource := TAccountsOperationsDataSource.Create(Self);
   FOperationsDataSource.Accounts := TCoreTool.GetUserAccountNumbers;
@@ -167,7 +168,7 @@ begin
     Width := 100;
     HeaderAlignment := taRightJustify;
     DataAlignment := taRightJustify;
-    Renderer := TCellRenderers.PASC;
+    Renderer := TCellRenderers.PASC_CheckPendingBalance;
     Filters := SORTABLE_NUMERIC_FILTER;
   end;
   FAccountsGRid.OnFinishedUpdating:= OnAccountsGridFinishedUpdating;

+ 11 - 6
src/gui/UCellRenderers.pas

@@ -40,7 +40,7 @@ type
 implementation
 
 uses
-  SysUtils, DateUtils, UCommon, UCommon.Data, UAccounts, UConst, UCoreUtils;
+  SysUtils, DateUtils, UCommon, UCommon.Data, UAccounts, UNode, UConst, UCoreUtils;
 
 const
   CT_PASCBALANCE_POS_COL = clGreen;
@@ -112,20 +112,25 @@ var
   LTextStyle: TTextStyle;
   LRowData : TDataRowData;
   LStr : AnsiString;
-  LAllBalance : boolean;
+  LAllBalance, LPending : boolean;
 begin
   if NOT TVariantTool.IsNumeric(CellData) then
     exit;
   LValue := CellData;
   LRowData := TDataRowData(RowData);
-  if LRowData.HasData('UnixTime')  AND (LRowData['UnixTime'] = 0) then begin
+  if LRowData.HasData('UnixTime')  AND (LRowData['UnixTime'] = 0) then
+    LPending := true
+  else if LRowData.HasData('LastUpdatedBlock') AND (LRowData['LastUpdatedBlock'] > TNode.Node.BlockTip) then
+    LPending := true
+  else
+    LPending := false;
+
+  if LPending then begin
     Canvas.Font.Color := CT_PASCBALANCE_0CONF_COL;
     LStr := '(' + TAccountComp.FormatMoney(LValue) + ')';
     Canvas.TextRect(Rect, Rect.Left, Rect.Top, LStr, Canvas.TextStyle);
     Handled := true;
-    exit;
-  end;
-  PASC(Sender, ACol, ARow, Canvas, Rect, State, CellData, RowData, Handled);
+  end else PASC(Sender, ACol, ARow, Canvas, Rect, State, CellData, RowData, Handled);
 end;
 
 class procedure TCellRenderers.PASC (Sender: TObject; ACol, ARow: Longint; Canvas: TCanvas; Rect: TRect; State: TGridDrawState; const CellData, RowData: Variant; var Handled: boolean);