|
@@ -82,7 +82,8 @@ type
|
|
procedure RefreshTotals;
|
|
procedure RefreshTotals;
|
|
procedure RefreshAccountsGrid;
|
|
procedure RefreshAccountsGrid;
|
|
procedure RefreshOperationsGrid;
|
|
procedure RefreshOperationsGrid;
|
|
- function GetAccounts(const AccountNumbers: TArray<cardinal>): TArray<TAccount>;
|
|
|
|
|
|
+ function GetSelectedAccounts : TArray<Cardinal>;
|
|
|
|
+ function GetAccNoWithoutChecksum(constref ARow: variant): cardinal;
|
|
protected
|
|
protected
|
|
procedure ActivateFirstTime; override;
|
|
procedure ActivateFirstTime; override;
|
|
procedure OnPrivateKeysChanged(Sender: TObject);
|
|
procedure OnPrivateKeysChanged(Sender: TObject);
|
|
@@ -94,6 +95,7 @@ type
|
|
procedure OnPrepareAccountPopupMenu(Sender: TObject; constref ASelection: TVisualGridSelection; out APopupMenu: TPopupMenu);
|
|
procedure OnPrepareAccountPopupMenu(Sender: TObject; constref ASelection: TVisualGridSelection; out APopupMenu: TPopupMenu);
|
|
procedure OnPrepareOperationsPopupMenu(Sender: TObject; constref ASelection: TVisualGridSelection; out APopupMenu: TPopupMenu);
|
|
procedure OnPrepareOperationsPopupMenu(Sender: TObject; constref ASelection: TVisualGridSelection; out APopupMenu: TPopupMenu);
|
|
public
|
|
public
|
|
|
|
+ property SelectedAccounts : TArray<Cardinal> read GetSelectedAccounts;
|
|
property AccountsMode: TCTRLWalletAccountsMode read FAccountsMode write SetAccountsMode;
|
|
property AccountsMode: TCTRLWalletAccountsMode read FAccountsMode write SetAccountsMode;
|
|
property OperationsMode: TCTRLWalletOperationsMode read FOperationsMode write SetOperationsMode;
|
|
property OperationsMode: TCTRLWalletOperationsMode read FOperationsMode write SetOperationsMode;
|
|
property OperationsHistory: TCTRLWalletOperationsHistory read FOperationsHistory write SetOperationsHistory;
|
|
property OperationsHistory: TCTRLWalletOperationsHistory read FOperationsHistory write SetOperationsHistory;
|
|
@@ -423,34 +425,9 @@ begin
|
|
FOperationsGrid.RefreshGrid;
|
|
FOperationsGrid.RefreshGrid;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TCTRLWallet.GetAccounts(const AccountNumbers: TArray<cardinal>): TArray<TAccount>;
|
|
|
|
-var
|
|
|
|
- acc: TAccount;
|
|
|
|
- safeBox: TPCSafeBox;
|
|
|
|
- keys: TOrderedAccountKeysList;
|
|
|
|
- LContainer: Generics.Collections.TList<TAccount>;
|
|
|
|
- i: integer;
|
|
|
|
|
|
+function TCTRLWallet.GetSelectedAccounts : TArray<Cardinal>;
|
|
begin
|
|
begin
|
|
- LContainer := Generics.Collections.TList<TAccount>.Create();
|
|
|
|
- keys := TWallet.keys.AccountsKeyList;
|
|
|
|
- safeBox := TUserInterface.Node.Bank.safeBox;
|
|
|
|
- safeBox.StartThreadSafe;
|
|
|
|
- try
|
|
|
|
- LContainer.Clear;
|
|
|
|
- try
|
|
|
|
- // load selected user accounts
|
|
|
|
- for i := Low(AccountNumbers) to High(AccountNumbers) do begin
|
|
|
|
- acc := safeBox.Account(AccountNumbers[i]);
|
|
|
|
- if keys.IndexOfAccountKey(acc.accountInfo.accountKey) >= 0 then
|
|
|
|
- LContainer.Add(acc);
|
|
|
|
- end;
|
|
|
|
- finally
|
|
|
|
- safeBox.EndThreadSave;
|
|
|
|
- end;
|
|
|
|
- Result := LContainer.ToArray;
|
|
|
|
- finally
|
|
|
|
- LContainer.Free;
|
|
|
|
- end;
|
|
|
|
|
|
+ Result := TListTool<Variant, Cardinal>.Transform(FAccountsGrid.SelectedRows, GetAccNoWithoutChecksum);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TCTRLWallet.SetAccountsMode(AMode: TCTRLWalletAccountsMode);
|
|
procedure TCTRLWallet.SetAccountsMode(AMode: TCTRLWalletAccountsMode);
|
|
@@ -486,10 +463,13 @@ end;
|
|
|
|
|
|
procedure TCTRLWallet.SetOperationsMode(AMode: TCTRLWalletOperationsMode);
|
|
procedure TCTRLWallet.SetOperationsMode(AMode: TCTRLWalletOperationsMode);
|
|
begin
|
|
begin
|
|
- if FOperationsMode = AMode then exit;
|
|
|
|
FUILock.Acquire;
|
|
FUILock.Acquire;
|
|
try
|
|
try
|
|
FOperationsMode := AMode;
|
|
FOperationsMode := AMode;
|
|
|
|
+ case AMode of
|
|
|
|
+ womSelectedAccounts: FOperationsDataSource.Accounts := SelectedAccounts;
|
|
|
|
+ womAllAccounts: FOperationsDataSource.Accounts := TCoreTool.GetUserAccountNumbers;
|
|
|
|
+ end;
|
|
RefreshOperationsGrid;
|
|
RefreshOperationsGrid;
|
|
finally
|
|
finally
|
|
FUILock.Release;
|
|
FUILock.Release;
|
|
@@ -500,9 +480,9 @@ procedure TCTRLWallet.SetOperationsHistory(AHistory: TCTRLWalletOperationsHistor
|
|
begin
|
|
begin
|
|
FOperationsHistory := AHistory;
|
|
FOperationsHistory := AHistory;
|
|
case FOperationsHistory of
|
|
case FOperationsHistory of
|
|
- woh7Days: FOperationsDataSource.TimeSpan := TTimeSpan.FromDays(7);
|
|
|
|
- woh30Days: FOperationsDataSource.TimeSpan := TTimeSpan.FromDays(30);
|
|
|
|
- wohFullHistory: FOperationsDataSource.TimeSpan := TTimeSpan.FromDays(10 * 365);
|
|
|
|
|
|
+ woh7Days: FOperationsDataSource.BlockDepth := TTimeSpan.FromDays(7).TotalBlockCount;
|
|
|
|
+ woh30Days: FOperationsDataSource.BlockDepth := TTimeSpan.FromDays(30).TotalBlockCount;
|
|
|
|
+ wohFullHistory: FOperationsDataSource.BlockDepth := TTimeSpan.FromDays(10 * 365).TotalBlockCount;
|
|
end;
|
|
end;
|
|
FOperationsGrid.RefreshGrid;
|
|
FOperationsGrid.RefreshGrid;
|
|
end;
|
|
end;
|
|
@@ -534,12 +514,9 @@ end;
|
|
|
|
|
|
procedure TCTRLWallet.OnAccountsSelected(Sender: TObject; constref ASelection: TVisualGridSelection);
|
|
procedure TCTRLWallet.OnAccountsSelected(Sender: TObject; constref ASelection: TVisualGridSelection);
|
|
begin
|
|
begin
|
|
- if ASelection.Page >= 0 then begin
|
|
|
|
- if OperationsMode <> womSelectedAccounts then
|
|
|
|
- OperationsMode := womSelectedAccounts
|
|
|
|
- else
|
|
|
|
- RefreshOperationsGrid // already viewing selected accounts, add to visible set
|
|
|
|
- end else
|
|
|
|
|
|
+ if ASelection.Page >= 0 then
|
|
|
|
+ OperationsMode := womSelectedAccounts
|
|
|
|
+ else
|
|
OperationsMode := womAllAccounts;
|
|
OperationsMode := womAllAccounts;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -622,18 +599,10 @@ var
|
|
Scoped: TDisposables;
|
|
Scoped: TDisposables;
|
|
wiz: TWIZSendPASCWizard;
|
|
wiz: TWIZSendPASCWizard;
|
|
model: TWIZOperationsModel;
|
|
model: TWIZOperationsModel;
|
|
- AccountNumbersWithoutChecksum: TArray<cardinal>;
|
|
|
|
-
|
|
|
|
- function GetAccNoWithoutChecksum(constref ARow: variant): cardinal;
|
|
|
|
- begin
|
|
|
|
- Result := ARow.__KEY;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
begin
|
|
begin
|
|
wiz := Scoped.AddObject(TWIZSendPASCWizard.Create(nil)) as TWIZSendPASCWizard;
|
|
wiz := Scoped.AddObject(TWIZSendPASCWizard.Create(nil)) as TWIZSendPASCWizard;
|
|
model := TWIZOperationsModel.Create(wiz, omtSendPasc);
|
|
model := TWIZOperationsModel.Create(wiz, omtSendPasc);
|
|
- AccountNumbersWithoutChecksum := TListTool<variant, cardinal>.Transform(FAccountsGrid.SelectedRows,GetAccNoWithoutChecksum);
|
|
|
|
- model.Account.SelectedAccounts := GetAccounts(AccountNumbersWithoutChecksum);
|
|
|
|
|
|
+ model.Account.SelectedAccounts := TNode.Node.GetAccounts(SelectedAccounts, True);
|
|
wiz.Start(model);
|
|
wiz.Start(model);
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -642,18 +611,10 @@ var
|
|
Scoped: TDisposables;
|
|
Scoped: TDisposables;
|
|
wiz: TWIZChangeKeyWizard;
|
|
wiz: TWIZChangeKeyWizard;
|
|
model: TWIZOperationsModel;
|
|
model: TWIZOperationsModel;
|
|
- AccountNumbersWithoutChecksum: TArray<cardinal>;
|
|
|
|
-
|
|
|
|
- function GetAccNoWithoutChecksum(constref ARow: variant): cardinal;
|
|
|
|
- begin
|
|
|
|
- Result := ARow.__KEY;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
begin
|
|
begin
|
|
wiz := Scoped.AddObject(TWIZChangeKeyWizard.Create(nil)) as TWIZChangeKeyWizard;
|
|
wiz := Scoped.AddObject(TWIZChangeKeyWizard.Create(nil)) as TWIZChangeKeyWizard;
|
|
model := TWIZOperationsModel.Create(wiz, omtChangeKey);
|
|
model := TWIZOperationsModel.Create(wiz, omtChangeKey);
|
|
- AccountNumbersWithoutChecksum := TListTool<variant, cardinal>.Transform(FAccountsGrid.SelectedRows, GetAccNoWithoutChecksum);
|
|
|
|
- model.Account.SelectedAccounts := GetAccounts(AccountNumbersWithoutChecksum);
|
|
|
|
|
|
+ model.Account.SelectedAccounts := TNode.Node.GetAccounts(SelectedAccounts, True);
|
|
wiz.Start(model);
|
|
wiz.Start(model);
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -662,19 +623,10 @@ var
|
|
Scoped: TDisposables;
|
|
Scoped: TDisposables;
|
|
wiz: TWIZEnlistAccountForSaleWizard;
|
|
wiz: TWIZEnlistAccountForSaleWizard;
|
|
model: TWIZOperationsModel;
|
|
model: TWIZOperationsModel;
|
|
- AccountNumbersWithoutChecksum: TArray<cardinal>;
|
|
|
|
-
|
|
|
|
- function GetAccNoWithoutChecksum(constref ARow: variant): cardinal;
|
|
|
|
- begin
|
|
|
|
- Result := ARow.__KEY;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
begin
|
|
begin
|
|
wiz := Scoped.AddObject(TWIZEnlistAccountForSaleWizard.Create(nil)) as TWIZEnlistAccountForSaleWizard;
|
|
wiz := Scoped.AddObject(TWIZEnlistAccountForSaleWizard.Create(nil)) as TWIZEnlistAccountForSaleWizard;
|
|
model := TWIZOperationsModel.Create(wiz, omtEnlistAccountForSale);
|
|
model := TWIZOperationsModel.Create(wiz, omtEnlistAccountForSale);
|
|
- AccountNumbersWithoutChecksum := TListTool<variant, cardinal>.Transform(FAccountsGrid.SelectedRows, GetAccNoWithoutChecksum);
|
|
|
|
- model.Account.SelectedAccounts := GetAccounts(AccountNumbersWithoutChecksum);
|
|
|
|
|
|
+ model.Account.SelectedAccounts := TNode.Node.GetAccounts(SelectedAccounts, True);
|
|
wiz.Start(model);
|
|
wiz.Start(model);
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -707,4 +659,11 @@ begin
|
|
TUserInterface.ShowOperationInfoDialog(Self, FOperationsGrid.SelectedRows[0].__KEY);
|
|
TUserInterface.ShowOperationInfoDialog(Self, FOperationsGrid.SelectedRows[0].__KEY);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+{ Aux methods }
|
|
|
|
+
|
|
|
|
+function TCTRLWallet.GetAccNoWithoutChecksum(constref ARow: variant): cardinal;
|
|
|
|
+begin
|
|
|
|
+ Result := ARow.__KEY;
|
|
|
|
+end;
|
|
|
|
+
|
|
end.
|
|
end.
|