Browse Source

Merge downstream

Herman Schoenfeld 7 years ago
parent
commit
3fca4984ad

+ 8 - 1
src/core.utils/UCoreUtils.pas

@@ -18,7 +18,7 @@ interface
 
 uses
   Classes, SysUtils, UCrypto, UAccounts, UBlockChain, UOpTransaction, UNode, UCommon, UNetProtocol,
-  Generics.Collections, Generics.Defaults, UCoreObjects, UWIZModels, Forms, Dialogs, LCLType;
+  Generics.Collections, Generics.Defaults, UCoreObjects, UWIZModels, Forms, Dialogs, LCLType, UCellRenderers;
 
 type
 
@@ -73,6 +73,7 @@ type
     class function ChangeKeyFinalizeAndDisplayMessage(const AOperationsTxt, AOperationToString: string; ANoOfOperations: integer; APublicKey: TAccountKey; ATotalFee: int64; AOperationsHashTree: TOperationsHashTree; var AErrorMessage: string): boolean; static;
     class function UpdateChangeKeyPayload(const ASenderAccount: TAccount; const APublicKey: TAccountKey; const APayloadEncryptionMode: TWIZOperationsModel.TPayloadEncryptionMode; const APayloadContent: string; var AEncodedPayloadBytes: TRawBytes; const APayloadEncryptionPassword: string; var AErrorMessage: string): boolean;
   public
+    class function GetOperationShortText(const OpType, OpSubType : DWord) : AnsiString; static; inline;
     class function ExecuteSendPASC(const ASelectedAccounts: TArray<TAccount>; const ADestinationAccount, ASignerAccount: TAccount; AAmount, AFee: int64; const ASendPASCMode: TWIZOperationsModel.TSendPASCMode; const APayloadEncryptionMode: TWIZOperationsModel.TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; var AErrorMessage: string): boolean; static;
     class function ExecuteChangeKey(const ASelectedAccounts: TArray<TAccount>; const ASignerAccount: TAccount; APublicKey: TAccountKey; AFee: int64; const APayloadEncryptionMode: TWIZOperationsModel.TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; var AErrorMessage: string): boolean; static;
     class procedure ExecuteEnlistAccountForSale(); static;
@@ -370,6 +371,12 @@ begin
   end;
 end;
 
+class function TOperationsManager.GetOperationShortText(const OpType,
+  OpSubType: DWord): AnsiString;
+begin
+  Result := TCellRenderers.OperationShortText(OpType, OpSubType);
+end;
+
 class function TOperationsManager.ExecuteSendPASC(const ASelectedAccounts: TArray<TAccount>; const ADestinationAccount, ASignerAccount: TAccount; AAmount, AFee: int64; const ASendPASCMode: TWIZOperationsModel.TSendPASCMode; const APayloadEncryptionMode: TWIZOperationsModel.TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; var AErrorMessage: string): boolean;
 var
   LWalletKey: TWalletKey;

+ 4 - 20
src/gui/wizards/operations/UWIZSendPASC_Confirmation.lfm → src/gui/wizards/operations/UWIZOperationConfirmation.lfm

@@ -1,9 +1,9 @@
-object WIZSendPASC_Confirmation: TWIZSendPASC_Confirmation
+object WIZOperationConfirmation: TWIZOperationConfirmation
   Left = 0
   Height = 320
   Top = 0
   Width = 511
-  Caption = 'WIZSendPASC_Confirmation'
+  Caption = 'WIZOperationConfirmation'
   ClientHeight = 320
   ClientWidth = 511
   Visible = False
@@ -19,8 +19,8 @@ object WIZSendPASC_Confirmation: TWIZSendPASC_Confirmation
     TabOrder = 0
     object paGrid: TPanel
       Left = 8
-      Height = 123
-      Top = 48
+      Height = 147
+      Top = 24
       Width = 464
       Anchors = [akTop, akLeft, akRight, akBottom]
       BevelOuter = bvNone
@@ -43,22 +43,6 @@ object WIZSendPASC_Confirmation: TWIZSendPASC_Confirmation
       Caption = 'lblSgnAcc'
       ParentColor = False
     end
-    object Label2: TLabel
-      Left = 8
-      Height = 15
-      Top = 24
-      Width = 111
-      Caption = 'Destination Account:'
-      ParentColor = False
-    end
-    object lblDestAcc: TLabel
-      Left = 128
-      Height = 15
-      Top = 24
-      Width = 56
-      Caption = 'lblDestAcc'
-      ParentColor = False
-    end
     object mmoPayload: TMemo
       Left = 8
       Height = 82

+ 62 - 57
src/gui/wizards/operations/UWIZSendPASC_Confirmation.pas → src/gui/wizards/operations/UWIZOperationConfirmation.pas

@@ -1,4 +1,4 @@
-unit UWIZSendPASC_Confirmation;
+unit UWIZOperationConfirmation;
 
 {$mode delphi}
 {$modeswitch nestedprocvars}
@@ -17,23 +17,21 @@ interface
 
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  ExtCtrls, UVisualGrid, UCellRenderers, UCommon.Data, UWizard, UWIZSendPASC, UWIZModels;
+  ExtCtrls, UVisualGrid, UCellRenderers, UCommon.Data, UWizard, UWIZModels;
 
 type
 
-  { TWIZSendPASC_Confirmation }
+  { TWIZOperationConfirmation }
 
-  TWIZSendPASC_Confirmation = class(TWizardForm<TWIZOperationsModel>)
+  TWIZOperationConfirmation = class(TWizardForm<TWIZOperationsModel>)
     GroupBox1: TGroupBox;
     Label1: TLabel;
-    Label2: TLabel;
     lblPayload: TLabel;
-    lblDestAcc: TLabel;
     lblSgnAcc: TLabel;
     mmoPayload: TMemo;
     paGrid: TPanel;
   private
-    FSendersGrid: TVisualGrid;
+    FConfirmationGrid: TVisualGrid;
   public
     procedure OnPresent; override;
     procedure OnNext; override;
@@ -44,7 +42,7 @@ implementation
 
 {$R *.lfm}
 
-uses UAccounts, UWallet, UUserInterface, UDataSources, UCommon, UCommon.UI, Generics.Collections, UCoreUtils;
+uses UAccounts, UConst, UWallet, UUserInterface, UDataSources, UCommon, UCommon.UI, Generics.Collections, UCoreUtils;
 
 type
 
@@ -53,6 +51,7 @@ type
   TAccountSenderDataSource = class(TAccountsDataSourceBase)
   private
     FModel: TWIZOperationsModel;
+
   protected
     function GetColumns: TDataColumns; override;
   public
@@ -61,22 +60,22 @@ type
     function GetItemField(constref AItem: TAccount; const ABindingName: ansistring): variant; override;
   end;
 
-{ TWIZSendPASC_Confirmation }
+{ TWIZOperationConfirmation }
 
-procedure TWIZSendPASC_Confirmation.OnPresent;
+procedure TWIZOperationConfirmation.OnPresent;
 var
   Data: TAccountSenderDataSource;
 begin
-  FSendersGrid := TVisualGrid.Create(Self);
-  FSendersGrid.CanSearch := False;
-  FSendersGrid.SortMode := smMultiColumn;
-  FSendersGrid.FetchDataInThread := False;
-  FSendersGrid.AutoPageSize := True;
-  FSendersGrid.SelectionType := stNone;
-  FSendersGrid.Options := [vgoColAutoFill, vgoColSizing, vgoSortDirectionAllowNone, vgoAutoHidePaging];
-  with FSendersGrid.AddColumn('Sender') do
+  FConfirmationGrid := TVisualGrid.Create(Self);
+  FConfirmationGrid.CanSearch := False;
+  FConfirmationGrid.SortMode := smMultiColumn;
+  FConfirmationGrid.FetchDataInThread := False;
+  FConfirmationGrid.AutoPageSize := True;
+  FConfirmationGrid.SelectionType := stNone;
+  FConfirmationGrid.Options := [vgoColAutoFill, vgoColSizing, vgoSortDirectionAllowNone, vgoAutoHidePaging];
+  with FConfirmationGrid.AddColumn('Sender') do
   begin
-    StretchedToFill:=true;
+    StretchedToFill := True;
     Binding := 'Account';
     SortBinding := 'AccountNumber';
     DisplayBinding := 'Display';
@@ -84,26 +83,33 @@ begin
     HeaderFontStyles := [fsBold];
     DataFontStyles := [fsBold];
   end;
-  with FSendersGrid.AddColumn('Balance') do
+  with FConfirmationGrid.AddColumn('Recipient') do
   begin
-    Filters := SORTABLE_NUMERIC_FILTER;
-    Width := 100;
-    Renderer := TCellRenderers.PASC;
+    StretchedToFill := True;
+    Filters := SORTABLE_TEXT_FILTER;
+    HeaderFontStyles := [fsBold];
+    DataFontStyles := [fsBold];
     HeaderAlignment := taRightJustify;
     DataAlignment := taRightJustify;
   end;
-  with FSendersGrid.AddColumn('Amount') do
+  with FConfirmationGrid.AddColumn('Operation') do
   begin
-    Binding := 'AmountDecimal';
-    SortBinding := 'Amount';
-    DisplayBinding := 'Amount';
+    StretchedToFill := True;
     Filters := SORTABLE_TEXT_FILTER;
+    HeaderFontStyles := [fsBold];
+    DataFontStyles := [fsBold];
+    HeaderAlignment := taRightJustify;
+    DataAlignment := taRightJustify;
+  end;
+  with FConfirmationGrid.AddColumn('Balance') do
+  begin
+    Filters := SORTABLE_NUMERIC_FILTER;
     Width := 100;
-    Renderer := TCellRenderers.PASC_CheckAllBalance;
+    Renderer := TCellRenderers.PASC;
     HeaderAlignment := taRightJustify;
     DataAlignment := taRightJustify;
   end;
-  with FSendersGrid.AddColumn('Fee') do
+  with FConfirmationGrid.AddColumn('Fee') do
   begin
     Filters := SORTABLE_NUMERIC_FILTER;
     Width := 50;
@@ -112,24 +118,21 @@ begin
     DataAlignment := taRightJustify;
   end;
 
-  Data := TAccountSenderDataSource.Create(FSendersGrid);
+  Data := TAccountSenderDataSource.Create(FConfirmationGrid);
   Data.Model := Model;
-  FSendersGrid.DataSource := Data;
-  paGrid.AddControlDockCenter(FSendersGrid);
+  FConfirmationGrid.DataSource := Data;
+  paGrid.AddControlDockCenter(FConfirmationGrid);
   lblSgnAcc.Caption := TAccountComp.AccountNumberToAccountTxtNumber(Model.Signer.SignerAccount.account);
-  lblDestAcc.Caption := TAccountComp.AccountNumberToAccountTxtNumber(Model.SendPASC.DestinationAccount.account);
   mmoPayload.Lines.Text := Model.Payload.Content;
 end;
 
-procedure TWIZSendPASC_Confirmation.OnNext;
+procedure TWIZOperationConfirmation.OnNext;
 var
-  locked: Boolean;
+  locked: boolean;
 begin
-  locked := (NOT TWallet.Keys.HasPassword) OR (NOT TWallet.Keys.IsValidPassword);
+  locked := (not TWallet.Keys.HasPassword) or (not TWallet.Keys.IsValidPassword);
   if locked then
-  begin
     TUserInterface.UnlockWallet(Self);
-  end;
 end;
 
 { TAccountSenderDataSource }
@@ -137,33 +140,37 @@ end;
 function TAccountSenderDataSource.GetColumns: TDataColumns;
 begin
   Result := TArrayTool<TDataColumn>.Concat([
-    Inherited,
+     Inherited,
     // Additional columns
     TDataColumns.Create(
-      TDataColumn.From('AllBalance'),
-      TDataColumn.From('Amount'),
-      TDataColumn.From('AmountDecimal'),
-      TDataColumn.From('Fee'),
-      TDataColumn.From('FeeDecimal')
+    TDataColumn.From('Operation'),
+    TDataColumn.From('Recipient'),
+    TDataColumn.From('Fee')
     )
-  ]);
+    ]);
 end;
 
 function TAccountSenderDataSource.GetItemField(constref AItem: TAccount; const ABindingName: ansistring): variant;
 var
-  index: integer;
+  LAmount: string;
 begin
-  if ABindingName = 'AllBalance' then
-    Result := IIF(Model.SendPASC.SendPASCMode = akaAllBalance, Variant(True), Variant(False))
-  else if ABindingName = 'Amount' then
-    Result := Variant(-Model.SendPASC.SingleAmountToSend)
-  else if ABindingName = 'AmountDecimal' then
-    Result := TAccountComp.FormatMoneyDecimal(-Model.SendPASC.SingleAmountToSend)
+  if ABindingName = 'Operation' then
+    case Model.ModelType of
+      omtSendPasc:
+      begin
+        Result := IIF(Model.SendPASC.SendPASCMode = akaAllBalance, 'All Balance', Format('%s ', [TAccountComp.FormatMoney(Model.SendPASC.SingleAmountToSend)]));
+        Result := Format('%s %s', [TOperationsManager.GetOperationShortText(CT_Op_Transaction, CT_OpSubtype_TransactionSender), Result]);
+      end;
+    end
+  else if ABindingName = 'Recipient' then
+    case Model.ModelType of
+      omtSendPasc:
+        Result := Model.SendPASC.DestinationAccount.AccountString;
+    end
   else if ABindingName = 'Fee' then
     Result := -Model.Fee.SingleOperationFee
-  else if ABindingName = 'FeeDecimal' then
-    Result := TAccountComp.FormatMoneyDecimal(-Model.Fee.SingleOperationFee)
-  else Result := Inherited GetItemField(AItem, ABindingName);
+  else
+    Result := inherited GetItemField(AItem, ABindingName);
 end;
 
 
@@ -172,9 +179,7 @@ var
   i: integer;
 begin
   for i := Low(Model.Account.SelectedAccounts) to High(Model.Account.SelectedAccounts) do
-  begin
     AContainer.Add(Model.Account.SelectedAccounts[i]);
-  end;
 end;
 
 

+ 3 - 3
src/gui/wizards/operations/UWIZSendPASC.pas

@@ -37,7 +37,7 @@ uses
   UWIZSendPASC_ConfirmSender,
   UWIZSendPASC_EnterRecipient,
   UWIZSendPASC_EnterQuantity,
-  UWIZSendPASC_Confirmation;
+  UWIZOperationConfirmation;
 
 { TWIZSendPASCWizard }
 
@@ -48,7 +48,7 @@ begin
     TWIZSendPASC_ConfirmSender,
     TWIZSendPASC_EnterRecipient,
     TWIZSendPASC_EnterQuantity,
-    TWIZSendPASC_Confirmation
+    TWIZOperationConfirmation
     ]
     );
   TitleText := 'Send PASC';
@@ -57,7 +57,7 @@ end;
 
 function TWIZSendPASCWizard.DetermineHasNext: boolean;
 begin
-  Result := not (CurrentScreen is TWIZSendPASC_Confirmation);
+  Result := not (CurrentScreen is TWIZOperationConfirmation);
 end;
 
 function TWIZSendPASCWizard.DetermineHasPrevious: boolean;

+ 1 - 0
src/gui/wizards/operations/UWIZSendPASC_EnterQuantity.lfm

@@ -7,6 +7,7 @@ object WIZSendPASC_EnterQuantity: TWIZSendPASC_EnterQuantity
   Caption = 'WIZSendPASC_EnterQuantity'
   ClientHeight = 253
   ClientWidth = 429
+  LCLVersion = '1.8.2.0'
   Visible = False
   object gbQuantity: TGroupBox
     Left = 16

+ 0 - 3
src/gui/wizards/operations/UWIZSendPASC_EnterQuantity.pas

@@ -35,9 +35,6 @@ type
     procedure UpdateUI();
     procedure chkallfundsChange(Sender: TObject);
 
-
-
-
   public
     procedure OnPresent; override;
     procedure OnNext; override;

+ 37 - 37
src/pascalcoin_wallet.lpi

@@ -457,121 +457,121 @@
         <IsPartOfProject Value="True"/>
       </Unit80>
       <Unit81>
-        <Filename Value="gui\wizards\operations\UWIZSendPASC_Confirmation.pas"/>
+        <Filename Value="gui\wizards\operations\UWIZSendPASC_ConfirmSender.pas"/>
         <IsPartOfProject Value="True"/>
-        <ComponentName Value="WIZSendPASC_Confirmation"/>
+        <ComponentName Value="WIZSendPASC_ConfirmSender"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
       </Unit81>
       <Unit82>
-        <Filename Value="gui\wizards\operations\UWIZSendPASC_ConfirmSender.pas"/>
+        <Filename Value="gui\wizards\operations\UWIZSendPASC_EnterQuantity.pas"/>
         <IsPartOfProject Value="True"/>
-        <ComponentName Value="WIZSendPASC_ConfirmSender"/>
+        <ComponentName Value="WIZSendPASC_EnterQuantity"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
       </Unit82>
       <Unit83>
-        <Filename Value="gui\wizards\operations\UWIZSendPASC_EnterQuantity.pas"/>
+        <Filename Value="gui\wizards\operations\UWIZSendPASC_EnterRecipient.pas"/>
         <IsPartOfProject Value="True"/>
-        <ComponentName Value="WIZSendPASC_EnterQuantity"/>
+        <ComponentName Value="WIZSendPASC_EnterRecipient"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
       </Unit83>
       <Unit84>
-        <Filename Value="gui\wizards\operations\UWIZSendPASC_EnterRecipient.pas"/>
+        <Filename Value="gui\wizards\operations\UWIZChangeKey.pas"/>
         <IsPartOfProject Value="True"/>
-        <ComponentName Value="WIZSendPASC_EnterRecipient"/>
-        <HasResources Value="True"/>
-        <ResourceBaseClass Value="Form"/>
       </Unit84>
       <Unit85>
-        <Filename Value="gui\wizards\operations\UWIZChangeKey.pas"/>
-        <IsPartOfProject Value="True"/>
-      </Unit85>
-      <Unit86>
         <Filename Value="gui\wizards\operations\UWIZChangeKey_SelectOption.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZChangeKey_SelectOption"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit86>
-      <Unit87>
+      </Unit85>
+      <Unit86>
         <Filename Value="gui\wizards\operations\UWIZChangeKey_EnterKey.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZChangeKey_EnterKey"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit87>
-      <Unit88>
+      </Unit86>
+      <Unit87>
         <Filename Value="gui\wizards\operations\UWIZChangeKey_SelectKey.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZChangeKey_SelectKey"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit88>
-      <Unit89>
+      </Unit87>
+      <Unit88>
         <Filename Value="gui\wizards\operations\UWIZChangeKey_ConfirmAccount.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZChangeKey_ConfirmAccount"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit89>
-      <Unit90>
+      </Unit88>
+      <Unit89>
         <Filename Value="gui\wizards\operations\UWIZChangeKey_Confirmation.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZChangeKey_Confirmation"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit90>
-      <Unit91>
+      </Unit89>
+      <Unit90>
         <Filename Value="gui-classic\UGridUtils.pas"/>
         <IsPartOfProject Value="True"/>
-      </Unit91>
-      <Unit92>
+      </Unit90>
+      <Unit91>
         <Filename Value="gui\wizards\operations\UWIZEnlistAccountForSale_EnterSeller.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZEnlistAccountForSale_EnterSeller"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit92>
-      <Unit93>
+      </Unit91>
+      <Unit92>
         <Filename Value="gui\wizards\operations\UWIZEnlistAccountForSale_EnterSaleAmount.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZEnlistAccountForSale_EnterSaleAmount"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit93>
-      <Unit94>
+      </Unit92>
+      <Unit93>
         <Filename Value="gui\wizards\operations\UWIZEnlistAccountForSale_SelectOption.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZEnlistAccountForSale_SelectOption"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit94>
-      <Unit95>
+      </Unit93>
+      <Unit94>
         <Filename Value="gui\wizards\operations\UWIZEnlistAccountForSale_EnterLockingBlock.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZEnlistAccountForSale_EnterLockingBlock"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit95>
-      <Unit96>
+      </Unit94>
+      <Unit95>
         <Filename Value="gui\wizards\operations\UWIZEnlistAccountForSale_EnterPublicKey.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZEnlistAccountForSale_EnterPublicKey"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit96>
-      <Unit97>
+      </Unit95>
+      <Unit96>
         <Filename Value="gui\wizards\operations\UWIZEnlistAccountForSale_ConfirmAccount.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZEnlistAccountForSale_ConfirmAccount"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
+      </Unit96>
+      <Unit97>
+        <Filename Value="core.utils\UCoreObjects.pas"/>
+        <IsPartOfProject Value="True"/>
       </Unit97>
       <Unit98>
-        <Filename Value="core.utils\UCoreObjects.pas"/>
+        <Filename Value="gui\wizards\operations\UWIZOperationConfirmation.pas"/>
         <IsPartOfProject Value="True"/>
+        <ComponentName Value="WIZOperationConfirmation"/>
+        <HasResources Value="True"/>
+        <ResourceBaseClass Value="Form"/>
       </Unit98>
     </Units>
   </ProjectOptions>