|
@@ -57,6 +57,7 @@ Type
|
|
FAccountsGridFilter : TAccountsGridFilter;
|
|
FAccountsGridFilter : TAccountsGridFilter;
|
|
FBalance : Int64;
|
|
FBalance : Int64;
|
|
FIsProcessing : Boolean;
|
|
FIsProcessing : Boolean;
|
|
|
|
+ FProcessedList : TOrderedCardinalList;
|
|
protected
|
|
protected
|
|
procedure SynchronizedOnTerminated;
|
|
procedure SynchronizedOnTerminated;
|
|
procedure BCExecute; override;
|
|
procedure BCExecute; override;
|
|
@@ -81,8 +82,15 @@ Type
|
|
FAccountsGridFilter: TAccountsGridFilter;
|
|
FAccountsGridFilter: TAccountsGridFilter;
|
|
FOnAccountsGridUpdatedData: TNotifyEvent;
|
|
FOnAccountsGridUpdatedData: TNotifyEvent;
|
|
FAccountsGridDatasource: TAccountsGridDatasource;
|
|
FAccountsGridDatasource: TAccountsGridDatasource;
|
|
|
|
+ //
|
|
|
|
+ FBufferLastAccountNumber : Integer;
|
|
|
|
+ FBufferLastAccount : TAccount;
|
|
|
|
+ FBufferNodeAccountsCount : Integer;
|
|
|
|
+ FBufferNodeBlocksCount : Integer;
|
|
|
|
+ //
|
|
procedure SetDrawGrid(const Value: TDrawGrid);
|
|
procedure SetDrawGrid(const Value: TDrawGrid);
|
|
Procedure InitGrid;
|
|
Procedure InitGrid;
|
|
|
|
+ Procedure InitGridRowCount;
|
|
Procedure OnNodeNewOperation(Sender : TObject);
|
|
Procedure OnNodeNewOperation(Sender : TObject);
|
|
procedure OnGridDrawCell(Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState);
|
|
procedure OnGridDrawCell(Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState);
|
|
procedure SetNode(const Value: TNode);
|
|
procedure SetNode(const Value: TNode);
|
|
@@ -95,6 +103,7 @@ Type
|
|
procedure UpdateAccountsBalance;
|
|
procedure UpdateAccountsBalance;
|
|
protected
|
|
protected
|
|
procedure Notification(AComponent: TComponent; Operation: TOperation); Override;
|
|
procedure Notification(AComponent: TComponent; Operation: TOperation); Override;
|
|
|
|
+ procedure BufferGetAccount(AAccountNumber : Integer; var AAccount : TAccount; var ANodeBlocksCount, ANodeAccountsCount : Integer);
|
|
public
|
|
public
|
|
Constructor Create(AOwner : TComponent); override;
|
|
Constructor Create(AOwner : TComponent); override;
|
|
Destructor Destroy; override;
|
|
Destructor Destroy; override;
|
|
@@ -271,7 +280,7 @@ uses
|
|
{ TAccountsGridUpdateThread }
|
|
{ TAccountsGridUpdateThread }
|
|
|
|
|
|
procedure TAccountsGridUpdateThread.BCExecute;
|
|
procedure TAccountsGridUpdateThread.BCExecute;
|
|
-Var Laccl, LacclTemp : TOrderedCardinalList;
|
|
|
|
|
|
+Var
|
|
l : TOrderedCardinalList;
|
|
l : TOrderedCardinalList;
|
|
i,j : Integer;
|
|
i,j : Integer;
|
|
c : Cardinal;
|
|
c : Cardinal;
|
|
@@ -283,10 +292,6 @@ begin
|
|
FBalance := 0;
|
|
FBalance := 0;
|
|
LNode := FAccountsGrid.Node;
|
|
LNode := FAccountsGrid.Node;
|
|
try
|
|
try
|
|
- Laccl := TOrderedCardinalList.Create;
|
|
|
|
- Try
|
|
|
|
- Laccl.Clear;
|
|
|
|
-
|
|
|
|
if (Assigned(FAccountsGridFilter.OrderedAccountsKeyList)) then begin
|
|
if (Assigned(FAccountsGridFilter.OrderedAccountsKeyList)) then begin
|
|
if (FAccountsGridFilter.indexAccountsKeyList<0) then i := 0
|
|
if (FAccountsGridFilter.indexAccountsKeyList<0) then i := 0
|
|
else i := FAccountsGridFilter.indexAccountsKeyList;
|
|
else i := FAccountsGridFilter.indexAccountsKeyList;
|
|
@@ -302,11 +307,11 @@ begin
|
|
LAccount := LNode.Bank.SafeBox.Account(l.Get(j));
|
|
LAccount := LNode.Bank.SafeBox.Account(l.Get(j));
|
|
if LApplyfilter then begin
|
|
if LApplyfilter then begin
|
|
if (LAccount.balance>=FAccountsGridFilter.MinBalance) And ((FAccountsGridFilter.MaxBalance<0) Or (LAccount.balance<=FAccountsGridFilter.MaxBalance)) then begin
|
|
if (LAccount.balance>=FAccountsGridFilter.MinBalance) And ((FAccountsGridFilter.MaxBalance<0) Or (LAccount.balance<=FAccountsGridFilter.MaxBalance)) then begin
|
|
- Laccl.Add(LAccount.account);
|
|
|
|
|
|
+ FProcessedList.Add(LAccount.account);
|
|
FBalance := FBalance + LAccount.balance;
|
|
FBalance := FBalance + LAccount.balance;
|
|
end;
|
|
end;
|
|
end else begin
|
|
end else begin
|
|
- Laccl.Add(LAccount.account);
|
|
|
|
|
|
+ FProcessedList.Add(LAccount.account);
|
|
FBalance := FBalance + LAccount.balance;
|
|
FBalance := FBalance + LAccount.balance;
|
|
end;
|
|
end;
|
|
if Terminated then Exit;
|
|
if Terminated then Exit;
|
|
@@ -322,26 +327,12 @@ begin
|
|
while (c<LNode.Bank.SafeBox.AccountsCount) and (Not Terminated) do begin
|
|
while (c<LNode.Bank.SafeBox.AccountsCount) and (Not Terminated) do begin
|
|
LAccount := LNode.Bank.SafeBox.Account(c);
|
|
LAccount := LNode.Bank.SafeBox.Account(c);
|
|
if (LAccount.balance>=FAccountsGridFilter.MinBalance) And ((FAccountsGridFilter.MaxBalance<0) Or (LAccount.balance<=FAccountsGridFilter.MaxBalance)) then begin
|
|
if (LAccount.balance>=FAccountsGridFilter.MinBalance) And ((FAccountsGridFilter.MaxBalance<0) Or (LAccount.balance<=FAccountsGridFilter.MaxBalance)) then begin
|
|
- Laccl.Add(LAccount.account);
|
|
|
|
|
|
+ FProcessedList.Add(LAccount.account);
|
|
FBalance := FBalance + LAccount.balance;
|
|
FBalance := FBalance + LAccount.balance;
|
|
end;
|
|
end;
|
|
inc(c);
|
|
inc(c);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
- Finally
|
|
|
|
- try
|
|
|
|
- if Not Terminated then begin
|
|
|
|
- LacclTemp := FAccountsGrid.LockAccountsList;
|
|
|
|
- try
|
|
|
|
- LacclTemp.CopyFrom(Laccl);
|
|
|
|
- finally
|
|
|
|
- FAccountsGrid.UnlockAccountsList;
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
- finally
|
|
|
|
- Laccl.Free;
|
|
|
|
- end;
|
|
|
|
- End;
|
|
|
|
Finally
|
|
Finally
|
|
FisProcessing := False;
|
|
FisProcessing := False;
|
|
if Not Terminated then
|
|
if Not Terminated then
|
|
@@ -356,18 +347,29 @@ begin
|
|
FAccountsGrid := AAccountsGrid;
|
|
FAccountsGrid := AAccountsGrid;
|
|
FAccountsGridFilter := AAccountsGridFilter;
|
|
FAccountsGridFilter := AAccountsGridFilter;
|
|
FisProcessing := True;
|
|
FisProcessing := True;
|
|
|
|
+ FProcessedList := TOrderedCardinalList.Create;
|
|
Suspended := False;
|
|
Suspended := False;
|
|
end;
|
|
end;
|
|
|
|
|
|
destructor TAccountsGridUpdateThread.Destroy;
|
|
destructor TAccountsGridUpdateThread.Destroy;
|
|
begin
|
|
begin
|
|
|
|
+ FreeAndNil(FProcessedList);
|
|
inherited;
|
|
inherited;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TAccountsGridUpdateThread.SynchronizedOnTerminated;
|
|
procedure TAccountsGridUpdateThread.SynchronizedOnTerminated;
|
|
|
|
+var LacclTemp : TOrderedCardinalList;
|
|
begin
|
|
begin
|
|
- FAccountsGrid.FAccountsBalance := FBalance;
|
|
|
|
- if Assigned(FAccountsGrid.FOnAccountsGridUpdatedData) then FAccountsGrid.FOnAccountsGridUpdatedData(FAccountsGrid);
|
|
|
|
|
|
+ if Not Terminated then begin
|
|
|
|
+ FAccountsGrid.FAccountsBalance := FBalance;
|
|
|
|
+ LacclTemp := FAccountsGrid.LockAccountsList;
|
|
|
|
+ try
|
|
|
|
+ LacclTemp.CopyFrom( FProcessedList );
|
|
|
|
+ finally
|
|
|
|
+ FAccountsGrid.UnlockAccountsList;
|
|
|
|
+ end;
|
|
|
|
+ if Assigned(FAccountsGrid.FOnAccountsGridUpdatedData) then FAccountsGrid.FOnAccountsGridUpdatedData(FAccountsGrid);
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TAccountsGrid }
|
|
{ TAccountsGrid }
|
|
@@ -387,6 +389,21 @@ begin
|
|
end else Result := -1;
|
|
end else Result := -1;
|
|
end;
|
|
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 FBufferLastAccount := Node.GetMempoolAccount(AAccountNumber);
|
|
|
|
+ FBufferNodeBlocksCount := Node.Bank.BlocksCount;
|
|
|
|
+ FBufferLastAccountNumber := AAccountNumber;
|
|
|
|
+ end;
|
|
|
|
+ AAccount := FBufferLastAccount;
|
|
|
|
+ ANodeBlocksCount := FBufferNodeBlocksCount;
|
|
|
|
+ ANodeAccountsCount := FBufferNodeAccountsCount;
|
|
|
|
+end;
|
|
|
|
+
|
|
constructor TAccountsGrid.Create(AOwner: TComponent);
|
|
constructor TAccountsGrid.Create(AOwner: TComponent);
|
|
Var i : Integer;
|
|
Var i : Integer;
|
|
begin
|
|
begin
|
|
@@ -417,6 +434,7 @@ begin
|
|
FOnAccountsGridUpdatedData := Nil;
|
|
FOnAccountsGridUpdatedData := Nil;
|
|
FAccountsGridFilter := CT_TAccountsGridFilter_NUL;
|
|
FAccountsGridFilter := CT_TAccountsGridFilter_NUL;
|
|
FAccountsGridDatasource := acds_Node;
|
|
FAccountsGridDatasource := acds_Node;
|
|
|
|
+ FBufferLastAccountNumber := -1;
|
|
end;
|
|
end;
|
|
|
|
|
|
destructor TAccountsGrid.Destroy;
|
|
destructor TAccountsGrid.Destroy;
|
|
@@ -430,7 +448,7 @@ end;
|
|
function TAccountsGrid.GetAccountsCount: Integer;
|
|
function TAccountsGrid.GetAccountsCount: Integer;
|
|
begin
|
|
begin
|
|
if Not Assigned(Node) then Exit(0);
|
|
if Not Assigned(Node) then Exit(0);
|
|
-
|
|
|
|
|
|
+
|
|
case FAccountsGridDatasource of
|
|
case FAccountsGridDatasource of
|
|
acds_Node: Result := Node.Bank.AccountsCount;
|
|
acds_Node: Result := Node.Bank.AccountsCount;
|
|
else
|
|
else
|
|
@@ -447,15 +465,7 @@ procedure TAccountsGrid.InitGrid;
|
|
Var i : Integer;
|
|
Var i : Integer;
|
|
begin
|
|
begin
|
|
if Not assigned(DrawGrid) then exit;
|
|
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;
|
|
DrawGrid.FixedRows := 1;
|
|
if Length(FColumns)=0 then DrawGrid.ColCount := 1
|
|
if Length(FColumns)=0 then DrawGrid.ColCount := 1
|
|
else DrawGrid.ColCount := Length(FColumns);
|
|
else DrawGrid.ColCount := Length(FColumns);
|
|
@@ -469,10 +479,29 @@ begin
|
|
{goColMoving, goEditing, }goTabs, goRowSelect, {goAlwaysShowEditor,}
|
|
{goColMoving, goEditing, }goTabs, goRowSelect, {goAlwaysShowEditor,}
|
|
goThumbTracking{$IFnDEF FPC}, goFixedColClick, goFixedRowClick, goFixedHotTrack{$ENDIF}];
|
|
goThumbTracking{$IFnDEF FPC}, goFixedColClick, goFixedRowClick, goFixedHotTrack{$ENDIF}];
|
|
if FAllowMultiSelect then DrawGrid.Options := DrawGrid.Options + [goRangeSelect];
|
|
if FAllowMultiSelect then DrawGrid.Options := DrawGrid.Options + [goRangeSelect];
|
|
|
|
+ FBufferLastAccountNumber := -1;
|
|
FDrawGrid.Invalidate;
|
|
FDrawGrid.Invalidate;
|
|
if Assigned(FOnUpdated) then FOnUpdated(Self);
|
|
if Assigned(FOnUpdated) then FOnUpdated(Self);
|
|
end;
|
|
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;
|
|
function TAccountsGrid.IsUpdatingData: Boolean;
|
|
begin
|
|
begin
|
|
if Assigned(FAccountsGridUpdateThread) then Result := FAccountsGridUpdateThread.IsProcessing
|
|
if Assigned(FAccountsGridUpdateThread) then Result := FAccountsGridUpdateThread.IsProcessing
|
|
@@ -588,7 +617,8 @@ Begin
|
|
end;
|
|
end;
|
|
{$ENDIF}
|
|
{$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;
|
|
Function FromColorToColor(colorstart,colordest : Integer; step,totalsteps : Integer) : Integer;
|
|
var sr,sg,sb,dr,dg,db : Byte;
|
|
var sr,sg,sb,dr,dg,db : Byte;
|
|
i : Integer;
|
|
i : Integer;
|
|
@@ -611,6 +641,7 @@ Var C : TAccountColumn;
|
|
n_acc : Int64;
|
|
n_acc : Int64;
|
|
account : TAccount;
|
|
account : TAccount;
|
|
ndiff : Cardinal;
|
|
ndiff : Cardinal;
|
|
|
|
+ LNodeBlocksCount,LNodeAccountsCount : Integer;
|
|
begin
|
|
begin
|
|
if Not Assigned(Node) then exit;
|
|
if Not Assigned(Node) then exit;
|
|
|
|
|
|
@@ -628,9 +659,8 @@ begin
|
|
end else begin
|
|
end else begin
|
|
n_acc := AccountNumber(ARow);
|
|
n_acc := AccountNumber(ARow);
|
|
if (n_acc>=0) then begin
|
|
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 (gdSelected in State) then
|
|
If (gdFocused in State) then DrawGrid.Canvas.Brush.Color := clGradientActiveCaption
|
|
If (gdFocused in State) then DrawGrid.Canvas.Brush.Color := clGradientActiveCaption
|
|
else DrawGrid.Canvas.Brush.Color := clGradientInactiveCaption
|
|
else DrawGrid.Canvas.Brush.Color := clGradientInactiveCaption
|
|
@@ -668,7 +698,7 @@ begin
|
|
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
|
|
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
|
|
End;
|
|
End;
|
|
act_updated_state : Begin
|
|
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;
|
|
DrawGrid.Canvas.Brush.Color := clRed;
|
|
end else if ndiff=0 then begin
|
|
end else if ndiff=0 then begin
|
|
DrawGrid.Canvas.Brush.Color := RGB(255,128,0);
|
|
DrawGrid.Canvas.Brush.Color := RGB(255,128,0);
|
|
@@ -692,7 +722,7 @@ begin
|
|
// Show price for sale
|
|
// Show price for sale
|
|
s := TAccountComp.FormatMoney(account.accountInfo.price);
|
|
s := TAccountComp.FormatMoney(account.accountInfo.price);
|
|
if TAccountComp.IsAccountForSaleAcceptingTransactions(account.accountInfo) then begin
|
|
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;
|
|
DrawGrid.Canvas.Font.Color := clNavy;
|
|
end else begin
|
|
end else begin
|
|
DrawGrid.Canvas.Font.Color := clRed;
|
|
DrawGrid.Canvas.Font.Color := clRed;
|
|
@@ -713,6 +743,7 @@ end;
|
|
|
|
|
|
procedure TAccountsGrid.OnNodeNewOperation(Sender: TObject);
|
|
procedure TAccountsGrid.OnNodeNewOperation(Sender: TObject);
|
|
begin
|
|
begin
|
|
|
|
+ FBufferLastAccountNumber := -1;
|
|
If Assigned(FDrawGrid) then FDrawGrid.Invalidate;
|
|
If Assigned(FDrawGrid) then FDrawGrid.Invalidate;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -804,7 +835,7 @@ end;
|
|
procedure TAccountsGrid.UnlockAccountsList;
|
|
procedure TAccountsGrid.UnlockAccountsList;
|
|
begin
|
|
begin
|
|
UpdateAccountsBalance;
|
|
UpdateAccountsBalance;
|
|
- InitGrid;
|
|
|
|
|
|
+ InitGridRowCount;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TAccountsGrid.UpdateAccountsBalance;
|
|
procedure TAccountsGrid.UpdateAccountsBalance;
|
|
@@ -837,7 +868,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
- InitGrid;
|
|
|
|
|
|
+ InitGridRowCount;
|
|
if Assigned(FOnAccountsGridUpdatedData) then FOnAccountsGridUpdatedData(Self);
|
|
if Assigned(FOnAccountsGridUpdatedData) then FOnAccountsGridUpdatedData(Self);
|
|
end;
|
|
end;
|
|
|
|
|