|
@@ -43,6 +43,31 @@ Type
|
|
width : Integer;
|
|
width : Integer;
|
|
End;
|
|
End;
|
|
|
|
|
|
|
|
+ TAccountsGrid = Class;
|
|
|
|
+
|
|
|
|
+ TAccountsGridFilter = Record
|
|
|
|
+ MinBalance,
|
|
|
|
+ MaxBalance : Int64;
|
|
|
|
+ OrderedAccountsKeyList : TOrderedAccountKeysList;
|
|
|
|
+ indexAccountsKeyList : Integer;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ TAccountsGridUpdateThread = Class(TPCThread)
|
|
|
|
+ FAccountsGrid : TAccountsGrid;
|
|
|
|
+ FAccountsGridFilter : TAccountsGridFilter;
|
|
|
|
+ FBalance : Int64;
|
|
|
|
+ FIsProcessing : Boolean;
|
|
|
|
+ protected
|
|
|
|
+ procedure SynchronizedOnTerminated;
|
|
|
|
+ procedure BCExecute; override;
|
|
|
|
+ public
|
|
|
|
+ constructor Create(AAccountsGrid : TAccountsGrid; AAccountsGridFilter : TAccountsGridFilter);
|
|
|
|
+ destructor Destroy; override;
|
|
|
|
+ property IsProcessing : Boolean read FisProcessing;
|
|
|
|
+ End;
|
|
|
|
+
|
|
|
|
+ TAccountsGridDatasource = (acds_Node, acds_InternalList, acds_NodeFiltered);
|
|
|
|
+
|
|
TAccountsGrid = Class(TComponent)
|
|
TAccountsGrid = Class(TComponent)
|
|
private
|
|
private
|
|
FAccountsBalance : Int64;
|
|
FAccountsBalance : Int64;
|
|
@@ -50,18 +75,24 @@ Type
|
|
FColumns : Array of TAccountColumn;
|
|
FColumns : Array of TAccountColumn;
|
|
FDrawGrid : TDrawGrid;
|
|
FDrawGrid : TDrawGrid;
|
|
FNodeNotifyEvents : TNodeNotifyEvents;
|
|
FNodeNotifyEvents : TNodeNotifyEvents;
|
|
- FShowAllAccounts: Boolean;
|
|
|
|
FOnUpdated: TNotifyEvent;
|
|
FOnUpdated: TNotifyEvent;
|
|
- FAccountsCount: Integer;
|
|
|
|
FAllowMultiSelect: Boolean;
|
|
FAllowMultiSelect: Boolean;
|
|
|
|
+ FAccountsGridUpdateThread : TAccountsGridUpdateThread;
|
|
|
|
+ FAccountsGridFilter: TAccountsGridFilter;
|
|
|
|
+ FOnAccountsGridUpdatedData: TNotifyEvent;
|
|
|
|
+ FAccountsGridDatasource: TAccountsGridDatasource;
|
|
procedure SetDrawGrid(const Value: TDrawGrid);
|
|
procedure SetDrawGrid(const Value: TDrawGrid);
|
|
Procedure InitGrid;
|
|
Procedure InitGrid;
|
|
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);
|
|
function GetNode: TNode;
|
|
function GetNode: TNode;
|
|
- procedure SetShowAllAccounts(const Value: Boolean);
|
|
|
|
procedure SetAllowMultiSelect(const Value: Boolean);
|
|
procedure SetAllowMultiSelect(const Value: Boolean);
|
|
|
|
+ procedure TerminateAccountGridUpdateThread;
|
|
|
|
+ procedure SetAccountsGridFilter(const Value: TAccountsGridFilter);
|
|
|
|
+ function GetAccountsCount: Integer;
|
|
|
|
+ procedure SetAccountsGridDatasource(const Value: TAccountsGridDatasource);
|
|
|
|
+ procedure UpdateAccountsBalance;
|
|
protected
|
|
protected
|
|
procedure Notification(AComponent: TComponent; Operation: TOperation); Override;
|
|
procedure Notification(AComponent: TComponent; Operation: TOperation); Override;
|
|
public
|
|
public
|
|
@@ -74,13 +105,17 @@ Type
|
|
Function AccountNumber(GridRow : Integer) : Int64;
|
|
Function AccountNumber(GridRow : Integer) : Int64;
|
|
Procedure SaveToStream(Stream : TStream);
|
|
Procedure SaveToStream(Stream : TStream);
|
|
Procedure LoadFromStream(Stream : TStream);
|
|
Procedure LoadFromStream(Stream : TStream);
|
|
- Property ShowAllAccounts : Boolean read FShowAllAccounts write SetShowAllAccounts;
|
|
|
|
Property AccountsBalance : Int64 read FAccountsBalance;
|
|
Property AccountsBalance : Int64 read FAccountsBalance;
|
|
- Property AccountsCount : Integer read FAccountsCount;
|
|
|
|
|
|
+ Property AccountsCount : Integer read GetAccountsCount;
|
|
Function MoveRowToAccount(nAccount : Cardinal) : Boolean;
|
|
Function MoveRowToAccount(nAccount : Cardinal) : Boolean;
|
|
Property OnUpdated : TNotifyEvent read FOnUpdated write FOnUpdated;
|
|
Property OnUpdated : TNotifyEvent read FOnUpdated write FOnUpdated;
|
|
Property AllowMultiSelect : Boolean read FAllowMultiSelect write SetAllowMultiSelect;
|
|
Property AllowMultiSelect : Boolean read FAllowMultiSelect write SetAllowMultiSelect;
|
|
Function SelectedAccounts(accounts : TOrderedCardinalList) : Integer;
|
|
Function SelectedAccounts(accounts : TOrderedCardinalList) : Integer;
|
|
|
|
+ property AccountsGridFilter : TAccountsGridFilter read FAccountsGridFilter write SetAccountsGridFilter;
|
|
|
|
+ procedure UpdateData;
|
|
|
|
+ function IsUpdatingData : Boolean;
|
|
|
|
+ property OnAccountsGridUpdatedData : TNotifyEvent read FOnAccountsGridUpdatedData write FOnAccountsGridUpdatedData;
|
|
|
|
+ property AccountsGridDatasource : TAccountsGridDatasource read FAccountsGridDatasource write SetAccountsGridDatasource;
|
|
End;
|
|
End;
|
|
|
|
|
|
TOperationsGrid = Class;
|
|
TOperationsGrid = Class;
|
|
@@ -225,7 +260,7 @@ Type
|
|
|
|
|
|
Const
|
|
Const
|
|
CT_TBlockChainData_NUL : TBlockChainData = (Block:0;Timestamp:0;BlockProtocolVersion:0;BlockProtocolAvailable:0;OperationsCount:-1;Volume:-1;Reward:0;Fee:0;Target:0;HashRateTargetHs:0;HashRateHs:0;HashRateTargetKhs:0;HashRateKhs:0;MinerPayload:Nil;PoW:Nil;SafeBoxHash:Nil;AccumulatedWork:0;TimeAverage200:0;TimeAverage150:0;TimeAverage100:0;TimeAverage75:0;TimeAverage50:0;TimeAverage25:0;TimeAverage10:0);
|
|
CT_TBlockChainData_NUL : TBlockChainData = (Block:0;Timestamp:0;BlockProtocolVersion:0;BlockProtocolAvailable:0;OperationsCount:-1;Volume:-1;Reward:0;Fee:0;Target:0;HashRateTargetHs:0;HashRateHs:0;HashRateTargetKhs:0;HashRateKhs:0;MinerPayload:Nil;PoW:Nil;SafeBoxHash:Nil;AccumulatedWork:0;TimeAverage200:0;TimeAverage150:0;TimeAverage100:0;TimeAverage75:0;TimeAverage50:0;TimeAverage25:0;TimeAverage10:0);
|
|
-
|
|
|
|
|
|
+ CT_TAccountsGridFilter_NUL : TAccountsGridFilter = (MinBalance:-1;MaxBalance:-1;OrderedAccountsKeyList:Nil;indexAccountsKeyList:-1);
|
|
|
|
|
|
implementation
|
|
implementation
|
|
|
|
|
|
@@ -233,6 +268,106 @@ uses
|
|
Graphics, SysUtils, UTime, UOpTransaction, UConst,
|
|
Graphics, SysUtils, UTime, UOpTransaction, UConst,
|
|
UFRMPayloadDecoder, ULog;
|
|
UFRMPayloadDecoder, ULog;
|
|
|
|
|
|
|
|
+{ TAccountsGridUpdateThread }
|
|
|
|
+
|
|
|
|
+procedure TAccountsGridUpdateThread.BCExecute;
|
|
|
|
+Var Laccl, LacclTemp : TOrderedCardinalList;
|
|
|
|
+ l : TOrderedCardinalList;
|
|
|
|
+ i,j : Integer;
|
|
|
|
+ c : Cardinal;
|
|
|
|
+ LApplyfilter : Boolean;
|
|
|
|
+ LAccount : TAccount;
|
|
|
|
+ LNode : TNode;
|
|
|
|
+begin
|
|
|
|
+ LApplyfilter := ((FAccountsGridFilter.MinBalance>0) Or ((FAccountsGridFilter.MaxBalance>=0) And (FAccountsGridFilter.MaxBalance<CT_MaxWalletAmount)));
|
|
|
|
+ FBalance := 0;
|
|
|
|
+ LNode := FAccountsGrid.Node;
|
|
|
|
+ try
|
|
|
|
+ Laccl := TOrderedCardinalList.Create;
|
|
|
|
+ Try
|
|
|
|
+ Laccl.Clear;
|
|
|
|
+
|
|
|
|
+ if (Assigned(FAccountsGridFilter.OrderedAccountsKeyList)) then begin
|
|
|
|
+ if (FAccountsGridFilter.indexAccountsKeyList<0) then i := 0
|
|
|
|
+ else i := FAccountsGridFilter.indexAccountsKeyList;
|
|
|
|
+
|
|
|
|
+ while (Not Terminated) and (i<FAccountsGridFilter.OrderedAccountsKeyList.Count)
|
|
|
|
+ and ((FAccountsGridFilter.indexAccountsKeyList<0) or (FAccountsGridFilter.indexAccountsKeyList=i)) do begin
|
|
|
|
+
|
|
|
|
+ FAccountsGridFilter.OrderedAccountsKeyList.Lock; // Protection v4
|
|
|
|
+ Try
|
|
|
|
+ l := FAccountsGridFilter.OrderedAccountsKeyList.AccountKeyList[i];
|
|
|
|
+ for j := 0 to l.Count - 1 do begin
|
|
|
|
+ LAccount := LNode.Bank.SafeBox.Account(l.Get(j));
|
|
|
|
+ if LApplyfilter then begin
|
|
|
|
+ if (LAccount.balance>=FAccountsGridFilter.MinBalance) And ((FAccountsGridFilter.MaxBalance<0) Or (LAccount.balance<=FAccountsGridFilter.MaxBalance)) then begin
|
|
|
|
+ Laccl.Add(LAccount.account);
|
|
|
|
+ FBalance := FBalance + LAccount.balance;
|
|
|
|
+ end;
|
|
|
|
+ end else begin
|
|
|
|
+ Laccl.Add(LAccount.account);
|
|
|
|
+ FBalance := FBalance + LAccount.balance;
|
|
|
|
+ end;
|
|
|
|
+ if Terminated then Exit;
|
|
|
|
+ end;
|
|
|
|
+ finally
|
|
|
|
+ FAccountsGridFilter.OrderedAccountsKeyList.Unlock;
|
|
|
|
+ end;
|
|
|
|
+ inc(i);
|
|
|
|
+ end;
|
|
|
|
+ end else begin
|
|
|
|
+ c := 0;
|
|
|
|
+ while (c<LNode.Bank.SafeBox.AccountsCount) and (Not Terminated) do begin
|
|
|
|
+ LAccount := LNode.Bank.SafeBox.Account(c);
|
|
|
|
+ if (LAccount.balance>=FAccountsGridFilter.MinBalance) And ((FAccountsGridFilter.MaxBalance<0) Or (LAccount.balance<=FAccountsGridFilter.MaxBalance)) then begin
|
|
|
|
+ Laccl.Add(LAccount.account);
|
|
|
|
+ FBalance := FBalance + LAccount.balance;
|
|
|
|
+ end;
|
|
|
|
+ inc(c);
|
|
|
|
+ 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
|
|
|
|
+ FisProcessing := False;
|
|
|
|
+ if Not Terminated then
|
|
|
|
+ Synchronize(SynchronizedOnTerminated);
|
|
|
|
+ End;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+constructor TAccountsGridUpdateThread.Create(AAccountsGrid: TAccountsGrid; AAccountsGridFilter: TAccountsGridFilter);
|
|
|
|
+begin
|
|
|
|
+ inherited Create(True);
|
|
|
|
+ FreeOnTerminate := False;
|
|
|
|
+ FAccountsGrid := AAccountsGrid;
|
|
|
|
+ FAccountsGridFilter := AAccountsGridFilter;
|
|
|
|
+ FisProcessing := True;
|
|
|
|
+ Suspended := False;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+destructor TAccountsGridUpdateThread.Destroy;
|
|
|
|
+begin
|
|
|
|
+ inherited;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TAccountsGridUpdateThread.SynchronizedOnTerminated;
|
|
|
|
+begin
|
|
|
|
+ FAccountsGrid.FAccountsBalance := FBalance;
|
|
|
|
+ if Assigned(FAccountsGrid.FOnAccountsGridUpdatedData) then FAccountsGrid.FOnAccountsGridUpdatedData(FAccountsGrid);
|
|
|
|
+end;
|
|
|
|
+
|
|
{ TAccountsGrid }
|
|
{ TAccountsGrid }
|
|
|
|
|
|
Const CT_ColumnHeader : Array[TAccountColumnType] Of String =
|
|
Const CT_ColumnHeader : Array[TAccountColumnType] Of String =
|
|
@@ -241,7 +376,7 @@ Const CT_ColumnHeader : Array[TAccountColumnType] Of String =
|
|
function TAccountsGrid.AccountNumber(GridRow: Integer): Int64;
|
|
function TAccountsGrid.AccountNumber(GridRow: Integer): Int64;
|
|
begin
|
|
begin
|
|
if GridRow<1 then Result := -1
|
|
if GridRow<1 then Result := -1
|
|
- else if FShowAllAccounts then begin
|
|
|
|
|
|
+ else if (FAccountsGridDatasource=acds_Node) then begin
|
|
if Assigned(Node) then begin
|
|
if Assigned(Node) then begin
|
|
Result := GridRow-1;
|
|
Result := GridRow-1;
|
|
end else Result := -1;
|
|
end else Result := -1;
|
|
@@ -257,8 +392,6 @@ begin
|
|
FAllowMultiSelect := false;
|
|
FAllowMultiSelect := false;
|
|
FOnUpdated := Nil;
|
|
FOnUpdated := Nil;
|
|
FAccountsBalance := 0;
|
|
FAccountsBalance := 0;
|
|
- FAccountsCount := 0;
|
|
|
|
- FShowAllAccounts := false;
|
|
|
|
FAccountsList := TOrderedCardinalList.Create;
|
|
FAccountsList := TOrderedCardinalList.Create;
|
|
FDrawGrid := Nil;
|
|
FDrawGrid := Nil;
|
|
SetLength(FColumns,7);
|
|
SetLength(FColumns,7);
|
|
@@ -278,15 +411,31 @@ begin
|
|
FColumns[6].width := 25;
|
|
FColumns[6].width := 25;
|
|
FNodeNotifyEvents := TNodeNotifyEvents.Create(Self);
|
|
FNodeNotifyEvents := TNodeNotifyEvents.Create(Self);
|
|
FNodeNotifyEvents.OnOperationsChanged := OnNodeNewOperation;
|
|
FNodeNotifyEvents.OnOperationsChanged := OnNodeNewOperation;
|
|
|
|
+ FAccountsGridUpdateThread := Nil;
|
|
|
|
+ FOnAccountsGridUpdatedData := Nil;
|
|
|
|
+ FAccountsGridFilter := CT_TAccountsGridFilter_NUL;
|
|
|
|
+ FAccountsGridDatasource := acds_Node;
|
|
end;
|
|
end;
|
|
|
|
|
|
destructor TAccountsGrid.Destroy;
|
|
destructor TAccountsGrid.Destroy;
|
|
begin
|
|
begin
|
|
|
|
+ TerminateAccountGridUpdateThread;
|
|
FNodeNotifyEvents.Free;
|
|
FNodeNotifyEvents.Free;
|
|
FAccountsList.Free;
|
|
FAccountsList.Free;
|
|
inherited;
|
|
inherited;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TAccountsGrid.GetAccountsCount: Integer;
|
|
|
|
+begin
|
|
|
|
+ if Not Assigned(Node) then Exit(0);
|
|
|
|
+
|
|
|
|
+ case FAccountsGridDatasource of
|
|
|
|
+ acds_Node: Result := Node.Bank.AccountsCount;
|
|
|
|
+ else
|
|
|
|
+ Result := FAccountsList.Count;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
function TAccountsGrid.GetNode: TNode;
|
|
function TAccountsGrid.GetNode: TNode;
|
|
begin
|
|
begin
|
|
Result := FNodeNotifyEvents.Node;
|
|
Result := FNodeNotifyEvents.Node;
|
|
@@ -294,26 +443,16 @@ end;
|
|
|
|
|
|
procedure TAccountsGrid.InitGrid;
|
|
procedure TAccountsGrid.InitGrid;
|
|
Var i : Integer;
|
|
Var i : Integer;
|
|
- acc : TAccount;
|
|
|
|
begin
|
|
begin
|
|
- FAccountsBalance := 0;
|
|
|
|
- FAccountsCount := FAccountsList.Count;
|
|
|
|
if Not assigned(DrawGrid) then exit;
|
|
if Not assigned(DrawGrid) then exit;
|
|
- if FShowAllAccounts then begin
|
|
|
|
|
|
+ if FAccountsGridDatasource=acds_Node then begin
|
|
if Assigned(Node) then begin
|
|
if Assigned(Node) then begin
|
|
if Node.Bank.AccountsCount<1 then DrawGrid.RowCount := 2
|
|
if Node.Bank.AccountsCount<1 then DrawGrid.RowCount := 2
|
|
else DrawGrid.RowCount := Node.Bank.AccountsCount+1;
|
|
else DrawGrid.RowCount := Node.Bank.AccountsCount+1;
|
|
- FAccountsBalance := Node.Bank.SafeBox.TotalBalance;
|
|
|
|
end else DrawGrid.RowCount := 2;
|
|
end else DrawGrid.RowCount := 2;
|
|
end else begin
|
|
end else begin
|
|
if FAccountsList.Count<1 then DrawGrid.RowCount := 2
|
|
if FAccountsList.Count<1 then DrawGrid.RowCount := 2
|
|
else DrawGrid.RowCount := FAccountsList.Count+1;
|
|
else DrawGrid.RowCount := FAccountsList.Count+1;
|
|
- if Assigned(Node) then begin
|
|
|
|
- for i := 0 to FAccountsList.Count - 1 do begin
|
|
|
|
- acc := Node.Bank.SafeBox.Account( FAccountsList.Get(i) );
|
|
|
|
- inc(FAccountsBalance, acc.balance);
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
end;
|
|
end;
|
|
DrawGrid.FixedRows := 1;
|
|
DrawGrid.FixedRows := 1;
|
|
if Length(FColumns)=0 then DrawGrid.ColCount := 1
|
|
if Length(FColumns)=0 then DrawGrid.ColCount := 1
|
|
@@ -332,6 +471,12 @@ begin
|
|
if Assigned(FOnUpdated) then FOnUpdated(Self);
|
|
if Assigned(FOnUpdated) then FOnUpdated(Self);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TAccountsGrid.IsUpdatingData: Boolean;
|
|
|
|
+begin
|
|
|
|
+ if Assigned(FAccountsGridUpdateThread) then Result := FAccountsGridUpdateThread.IsProcessing
|
|
|
|
+ else Result := False;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TAccountsGrid.LoadFromStream(Stream: TStream);
|
|
procedure TAccountsGrid.LoadFromStream(Stream: TStream);
|
|
Var c,i,j : Integer;
|
|
Var c,i,j : Integer;
|
|
begin
|
|
begin
|
|
@@ -364,7 +509,7 @@ begin
|
|
if Not Assigned(FDrawGrid) then exit;
|
|
if Not Assigned(FDrawGrid) then exit;
|
|
if Not Assigned(Node) then exit;
|
|
if Not Assigned(Node) then exit;
|
|
if FDrawGrid.RowCount<=1 then exit;
|
|
if FDrawGrid.RowCount<=1 then exit;
|
|
- if FShowAllAccounts then begin
|
|
|
|
|
|
+ if FAccountsGridDatasource=acds_Node then begin
|
|
If (FDrawGrid.RowCount>nAccount+1) And (nAccount>=0) And (nAccount<Node.Bank.AccountsCount) then begin
|
|
If (FDrawGrid.RowCount>nAccount+1) And (nAccount>=0) And (nAccount<Node.Bank.AccountsCount) then begin
|
|
FDrawGrid.Row := nAccount+1;
|
|
FDrawGrid.Row := nAccount+1;
|
|
Result := true;
|
|
Result := true;
|
|
@@ -608,6 +753,19 @@ begin
|
|
Result := accounts.Count;
|
|
Result := accounts.Count;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TAccountsGrid.SetAccountsGridDatasource(const Value: TAccountsGridDatasource);
|
|
|
|
+begin
|
|
|
|
+ if FAccountsGridDatasource=Value then Exit;
|
|
|
|
+ FAccountsGridDatasource := Value;
|
|
|
|
+ UpdateData;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TAccountsGrid.SetAccountsGridFilter(const Value: TAccountsGridFilter);
|
|
|
|
+begin
|
|
|
|
+ FAccountsGridFilter := Value;
|
|
|
|
+ UpdateData;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TAccountsGrid.SetAllowMultiSelect(const Value: Boolean);
|
|
procedure TAccountsGrid.SetAllowMultiSelect(const Value: Boolean);
|
|
begin
|
|
begin
|
|
FAllowMultiSelect := Value;
|
|
FAllowMultiSelect := Value;
|
|
@@ -621,7 +779,7 @@ begin
|
|
if Assigned(Value) then begin
|
|
if Assigned(Value) then begin
|
|
Value.FreeNotification(self);
|
|
Value.FreeNotification(self);
|
|
FDrawGrid.OnDrawCell := OnGridDrawCell;
|
|
FDrawGrid.OnDrawCell := OnGridDrawCell;
|
|
- InitGrid;
|
|
|
|
|
|
+ UpdateData;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -629,19 +787,56 @@ procedure TAccountsGrid.SetNode(const Value: TNode);
|
|
begin
|
|
begin
|
|
if GetNode=Value then exit;
|
|
if GetNode=Value then exit;
|
|
FNodeNotifyEvents.Node := Value;
|
|
FNodeNotifyEvents.Node := Value;
|
|
- InitGrid;
|
|
|
|
|
|
+ UpdateData;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TAccountsGrid.SetShowAllAccounts(const Value: Boolean);
|
|
|
|
|
|
+procedure TAccountsGrid.TerminateAccountGridUpdateThread;
|
|
begin
|
|
begin
|
|
- if FShowAllAccounts=Value then exit;
|
|
|
|
- FShowAllAccounts := Value;
|
|
|
|
- InitGrid;
|
|
|
|
|
|
+ if Assigned(FAccountsGridUpdateThread) then begin
|
|
|
|
+ FAccountsGridUpdateThread.Terminate;
|
|
|
|
+ FAccountsGridUpdateThread.WaitFor;
|
|
|
|
+ FreeAndNil(FAccountsGridUpdateThread);
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TAccountsGrid.UnlockAccountsList;
|
|
procedure TAccountsGrid.UnlockAccountsList;
|
|
begin
|
|
begin
|
|
|
|
+ UpdateAccountsBalance;
|
|
|
|
+ InitGrid;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TAccountsGrid.UpdateAccountsBalance;
|
|
|
|
+var i : Integer;
|
|
|
|
+ LAcc : TAccount;
|
|
|
|
+begin
|
|
|
|
+ if Assigned(Node) and (AccountsGridDatasource=acds_InternalList) then begin
|
|
|
|
+ FAccountsBalance := 0;
|
|
|
|
+ case FAccountsGridDatasource of
|
|
|
|
+ acds_Node: FAccountsBalance := Node.Bank.SafeBox.TotalBalance;
|
|
|
|
+ acds_InternalList: begin
|
|
|
|
+ for i := 0 to FAccountsList.Count - 1 do begin
|
|
|
|
+ LAcc := Node.Bank.SafeBox.Account( FAccountsList.Get(i) );
|
|
|
|
+ inc(FAccountsBalance, LAcc.balance);
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TAccountsGrid.UpdateData;
|
|
|
|
+begin
|
|
|
|
+ UpdateAccountsBalance;
|
|
|
|
+ if Assigned(Node) then begin
|
|
|
|
+ case FAccountsGridDatasource of
|
|
|
|
+ acds_NodeFiltered: begin
|
|
|
|
+ TerminateAccountGridUpdateThread;
|
|
|
|
+ FAccountsBalance := 0;
|
|
|
|
+ FAccountsGridUpdateThread := TAccountsGridUpdateThread.Create(Self,AccountsGridFilter);
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
InitGrid;
|
|
InitGrid;
|
|
|
|
+ if Assigned(FOnAccountsGridUpdatedData) then FOnAccountsGridUpdatedData(Self);
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TOperationsGridUpdateThread }
|
|
{ TOperationsGridUpdateThread }
|