|
@@ -82,8 +82,15 @@ Type
|
|
|
FAccountsGridFilter: TAccountsGridFilter;
|
|
|
FOnAccountsGridUpdatedData: TNotifyEvent;
|
|
|
FAccountsGridDatasource: TAccountsGridDatasource;
|
|
|
+ //
|
|
|
+ FBufferLastAccountNumber : Integer;
|
|
|
+ FBufferLastAccount : TAccount;
|
|
|
+ FBufferNodeAccountsCount : Integer;
|
|
|
+ FBufferNodeBlocksCount : Integer;
|
|
|
+ //
|
|
|
procedure SetDrawGrid(const Value: TDrawGrid);
|
|
|
Procedure InitGrid;
|
|
|
+ Procedure InitGridRowCount;
|
|
|
Procedure OnNodeNewOperation(Sender : TObject);
|
|
|
procedure OnGridDrawCell(Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState);
|
|
|
procedure SetNode(const Value: TNode);
|
|
@@ -96,6 +103,7 @@ Type
|
|
|
procedure UpdateAccountsBalance;
|
|
|
protected
|
|
|
procedure Notification(AComponent: TComponent; Operation: TOperation); Override;
|
|
|
+ procedure BufferGetAccount(AAccountNumber : Integer; var AAccount : TAccount; var ANodeBlocksCount, ANodeAccountsCount : Integer);
|
|
|
public
|
|
|
Constructor Create(AOwner : TComponent); override;
|
|
|
Destructor Destroy; override;
|
|
@@ -381,6 +389,21 @@ begin
|
|
|
end else Result := -1;
|
|
|
end;
|
|
|
|
|
|
+procedure TAccountsGrid.BufferGetAccount(AAccountNumber: Integer;
|
|
|
+ var AAccount: TAccount; var ANodeBlocksCount, ANodeAccountsCount: Integer);
|
|
|
+begin
|
|
|
+ if FBufferLastAccountNumber<>AAccountNumber then begin
|
|
|
+ FBufferNodeAccountsCount := Node.Bank.AccountsCount;
|
|
|
+ if (AAccountNumber>=FBufferNodeAccountsCount) then FBufferLastAccount := CT_Account_NUL
|
|
|
+ else Node.GetMempoolAccount(AAccountNumber);
|
|
|
+ FBufferNodeBlocksCount := Node.Bank.BlocksCount;
|
|
|
+ FBufferLastAccountNumber := AAccountNumber;
|
|
|
+ end;
|
|
|
+ AAccount := FBufferLastAccount;
|
|
|
+ ANodeBlocksCount := FBufferNodeBlocksCount;
|
|
|
+ ANodeAccountsCount := FBufferNodeAccountsCount;
|
|
|
+end;
|
|
|
+
|
|
|
constructor TAccountsGrid.Create(AOwner: TComponent);
|
|
|
Var i : Integer;
|
|
|
begin
|
|
@@ -411,6 +434,7 @@ begin
|
|
|
FOnAccountsGridUpdatedData := Nil;
|
|
|
FAccountsGridFilter := CT_TAccountsGridFilter_NUL;
|
|
|
FAccountsGridDatasource := acds_Node;
|
|
|
+ FBufferLastAccountNumber := -1;
|
|
|
end;
|
|
|
|
|
|
destructor TAccountsGrid.Destroy;
|
|
@@ -424,7 +448,7 @@ end;
|
|
|
function TAccountsGrid.GetAccountsCount: Integer;
|
|
|
begin
|
|
|
if Not Assigned(Node) then Exit(0);
|
|
|
-
|
|
|
+
|
|
|
case FAccountsGridDatasource of
|
|
|
acds_Node: Result := Node.Bank.AccountsCount;
|
|
|
else
|
|
@@ -441,15 +465,7 @@ procedure TAccountsGrid.InitGrid;
|
|
|
Var i : Integer;
|
|
|
begin
|
|
|
if Not assigned(DrawGrid) then exit;
|
|
|
- if FAccountsGridDatasource=acds_Node then begin
|
|
|
- if Assigned(Node) then begin
|
|
|
- if Node.Bank.AccountsCount<1 then DrawGrid.RowCount := 2
|
|
|
- else DrawGrid.RowCount := Node.Bank.AccountsCount+1;
|
|
|
- end else DrawGrid.RowCount := 2;
|
|
|
- end else begin
|
|
|
- if FAccountsList.Count<1 then DrawGrid.RowCount := 2
|
|
|
- else DrawGrid.RowCount := FAccountsList.Count+1;
|
|
|
- end;
|
|
|
+ InitGridRowCount;
|
|
|
DrawGrid.FixedRows := 1;
|
|
|
if Length(FColumns)=0 then DrawGrid.ColCount := 1
|
|
|
else DrawGrid.ColCount := Length(FColumns);
|
|
@@ -463,10 +479,29 @@ begin
|
|
|
{goColMoving, goEditing, }goTabs, goRowSelect, {goAlwaysShowEditor,}
|
|
|
goThumbTracking{$IFnDEF FPC}, goFixedColClick, goFixedRowClick, goFixedHotTrack{$ENDIF}];
|
|
|
if FAllowMultiSelect then DrawGrid.Options := DrawGrid.Options + [goRangeSelect];
|
|
|
+ FBufferLastAccountNumber := -1;
|
|
|
FDrawGrid.Invalidate;
|
|
|
if Assigned(FOnUpdated) then FOnUpdated(Self);
|
|
|
end;
|
|
|
|
|
|
+procedure TAccountsGrid.InitGridRowCount;
|
|
|
+var LRowCount : Integer;
|
|
|
+begin
|
|
|
+ if Not assigned(DrawGrid) then exit;
|
|
|
+ if FAccountsGridDatasource=acds_Node then begin
|
|
|
+ if Assigned(Node) then begin
|
|
|
+ if Node.Bank.AccountsCount<1 then LRowCount := 2
|
|
|
+ else LRowCount := Node.Bank.AccountsCount+1;
|
|
|
+ end else LRowCount := 2;
|
|
|
+ end else begin
|
|
|
+ if FAccountsList.Count<1 then LRowCount := 2
|
|
|
+ else LRowCount := FAccountsList.Count+1;
|
|
|
+ end;
|
|
|
+ if DrawGrid.RowCount<>LRowCount then DrawGrid.RowCount:=LRowCount;
|
|
|
+ FBufferLastAccountNumber := -1;
|
|
|
+ FDrawGrid.Invalidate;
|
|
|
+end;
|
|
|
+
|
|
|
function TAccountsGrid.IsUpdatingData: Boolean;
|
|
|
begin
|
|
|
if Assigned(FAccountsGridUpdateThread) then Result := FAccountsGridUpdateThread.IsProcessing
|
|
@@ -582,7 +617,8 @@ Begin
|
|
|
end;
|
|
|
{$ENDIF}
|
|
|
|
|
|
-procedure TAccountsGrid.OnGridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
|
|
|
+procedure TAccountsGrid.OnGridDrawCell(Sender: TObject; ACol, ARow: Longint;
|
|
|
+ Rect: TRect; State: TGridDrawState);
|
|
|
Function FromColorToColor(colorstart,colordest : Integer; step,totalsteps : Integer) : Integer;
|
|
|
var sr,sg,sb,dr,dg,db : Byte;
|
|
|
i : Integer;
|
|
@@ -605,6 +641,7 @@ Var C : TAccountColumn;
|
|
|
n_acc : Int64;
|
|
|
account : TAccount;
|
|
|
ndiff : Cardinal;
|
|
|
+ LNodeBlocksCount,LNodeAccountsCount : Integer;
|
|
|
begin
|
|
|
if Not Assigned(Node) then exit;
|
|
|
|
|
@@ -622,9 +659,8 @@ begin
|
|
|
end else begin
|
|
|
n_acc := AccountNumber(ARow);
|
|
|
if (n_acc>=0) then begin
|
|
|
- if (n_acc>=Node.Bank.AccountsCount) then account := CT_Account_NUL
|
|
|
- else account := Node.GetMempoolAccount(n_acc);
|
|
|
- ndiff := Node.Bank.BlocksCount - account.updated_block;
|
|
|
+ BufferGetAccount(n_acc,account,LNodeBlocksCount,LNodeAccountsCount);
|
|
|
+ ndiff := LNodeBlocksCount - account.updated_block;
|
|
|
if (gdSelected in State) then
|
|
|
If (gdFocused in State) then DrawGrid.Canvas.Brush.Color := clGradientActiveCaption
|
|
|
else DrawGrid.Canvas.Brush.Color := clGradientInactiveCaption
|
|
@@ -662,7 +698,7 @@ begin
|
|
|
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
|
|
|
End;
|
|
|
act_updated_state : Begin
|
|
|
- if TAccountComp.IsAccountBlockedByProtocol(account.account,Node.Bank.BlocksCount) then begin
|
|
|
+ if TAccountComp.IsAccountBlockedByProtocol(account.account,LNodeBlocksCount) then begin
|
|
|
DrawGrid.Canvas.Brush.Color := clRed;
|
|
|
end else if ndiff=0 then begin
|
|
|
DrawGrid.Canvas.Brush.Color := RGB(255,128,0);
|
|
@@ -686,7 +722,7 @@ begin
|
|
|
// Show price for sale
|
|
|
s := TAccountComp.FormatMoney(account.accountInfo.price);
|
|
|
if TAccountComp.IsAccountForSaleAcceptingTransactions(account.accountInfo) then begin
|
|
|
- if TAccountComp.IsAccountLocked(account.accountInfo,Node.Bank.BlocksCount) then begin
|
|
|
+ if TAccountComp.IsAccountLocked(account.accountInfo,LNodeBlocksCount) then begin
|
|
|
DrawGrid.Canvas.Font.Color := clNavy;
|
|
|
end else begin
|
|
|
DrawGrid.Canvas.Font.Color := clRed;
|
|
@@ -707,6 +743,7 @@ end;
|
|
|
|
|
|
procedure TAccountsGrid.OnNodeNewOperation(Sender: TObject);
|
|
|
begin
|
|
|
+ FBufferLastAccountNumber := -1;
|
|
|
If Assigned(FDrawGrid) then FDrawGrid.Invalidate;
|
|
|
end;
|
|
|
|
|
@@ -798,7 +835,7 @@ end;
|
|
|
procedure TAccountsGrid.UnlockAccountsList;
|
|
|
begin
|
|
|
UpdateAccountsBalance;
|
|
|
- InitGrid;
|
|
|
+ InitGridRowCount;
|
|
|
end;
|
|
|
|
|
|
procedure TAccountsGrid.UpdateAccountsBalance;
|
|
@@ -831,7 +868,7 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
end;
|
|
|
- InitGrid;
|
|
|
+ InitGridRowCount;
|
|
|
if Assigned(FOnAccountsGridUpdatedData) then FOnAccountsGridUpdatedData(Self);
|
|
|
end;
|
|
|
|