Browse Source

GUI account select improvements

Allow search/show SWAP accounts
PascalCoin 6 years ago
parent
commit
01a502e210

+ 10 - 7
src/gui-classic/UFRMAccountSelect.dfm

@@ -28,9 +28,9 @@ object FRMAccountSelect: TFRMAccountSelect
     object cbOnlyForSale: TCheckBox
     object cbOnlyForSale: TCheckBox
       Left = 10
       Left = 10
       Top = 65
       Top = 65
-      Width = 81
+      Width = 175
       Height = 19
       Height = 19
-      Caption = 'Only for sale'
+      Caption = 'Only for sale or swap'
       TabOrder = 2
       TabOrder = 2
     end
     end
     object bbSearch: TBitBtn
     object bbSearch: TBitBtn
@@ -102,7 +102,7 @@ object FRMAccountSelect: TFRMAccountSelect
     object cbOnlyForPrivateSaleToMe: TCheckBox
     object cbOnlyForPrivateSaleToMe: TCheckBox
       Left = 10
       Left = 10
       Top = 111
       Top = 111
-      Width = 148
+      Width = 175
       Height = 19
       Height = 19
       Caption = 'Only for private sale to me'
       Caption = 'Only for private sale to me'
       TabOrder = 4
       TabOrder = 4
@@ -110,7 +110,7 @@ object FRMAccountSelect: TFRMAccountSelect
     object cbAccountsBalance: TCheckBox
     object cbAccountsBalance: TCheckBox
       Left = 10
       Left = 10
       Top = 134
       Top = 134
-      Width = 104
+      Width = 167
       Height = 19
       Height = 19
       Caption = 'Accounts Balance'
       Caption = 'Accounts Balance'
       TabOrder = 5
       TabOrder = 5
@@ -118,7 +118,7 @@ object FRMAccountSelect: TFRMAccountSelect
     object cbMyAccounts: TCheckBox
     object cbMyAccounts: TCheckBox
       Left = 10
       Left = 10
       Top = 10
       Top = 10
-      Width = 81
+      Width = 175
       Height = 19
       Height = 19
       Caption = 'My Accounts'
       Caption = 'My Accounts'
       TabOrder = 0
       TabOrder = 0
@@ -136,7 +136,7 @@ object FRMAccountSelect: TFRMAccountSelect
     object cbOnlyForPublicSale: TCheckBox
     object cbOnlyForPublicSale: TCheckBox
       Left = 10
       Left = 10
       Top = 88
       Top = 88
-      Width = 111
+      Width = 175
       Height = 19
       Height = 19
       Caption = 'Only for public sale'
       Caption = 'Only for public sale'
       TabOrder = 3
       TabOrder = 3
@@ -160,7 +160,7 @@ object FRMAccountSelect: TFRMAccountSelect
     object cbAccountsName: TCheckBox
     object cbAccountsName: TCheckBox
       Left = 10
       Left = 10
       Top = 186
       Top = 186
-      Width = 93
+      Width = 167
       Height = 19
       Height = 19
       Caption = 'Accounts name'
       Caption = 'Accounts name'
       TabOrder = 8
       TabOrder = 8
@@ -257,6 +257,9 @@ object FRMAccountSelect: TFRMAccountSelect
     Width = 451
     Width = 451
     Height = 282
     Height = 282
     Align = alClient
     Align = alClient
+    ColCount = 6
+    FixedCols = 0
+    Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRowSelect]
     TabOrder = 2
     TabOrder = 2
   end
   end
 end
 end

+ 30 - 9
src/gui-classic/UFRMAccountSelect.pas

@@ -42,7 +42,7 @@ type
     SafeBox : TPCSafeBox;
     SafeBox : TPCSafeBox;
     inWalletKeys : TWalletKeys;
     inWalletKeys : TWalletKeys;
     inAccountKey : TAccountKey;
     inAccountKey : TAccountKey;
-    onlyForSale,
+    onlyForSaleOrSwap,
     onlyForPublicSale,
     onlyForPublicSale,
     onlyForPrivateSaleToMe : Boolean;
     onlyForPrivateSaleToMe : Boolean;
     minBal,maxBal : Int64;
     minBal,maxBal : Int64;
@@ -175,17 +175,20 @@ procedure TSearchThread.BCExecute;
       end else if (Assigned(FSearchValues.inWalletKeys)) then begin
       end else if (Assigned(FSearchValues.inWalletKeys)) then begin
         isValid := FSearchValues.inWalletKeys.IndexOfAccountKey(account.accountInfo.accountKey)>=0;
         isValid := FSearchValues.inWalletKeys.IndexOfAccountKey(account.accountInfo.accountKey)>=0;
       end;
       end;
-      If isValid And (FSearchValues.onlyForSale) then begin
-        isValid := TAccountComp.IsAccountForSale(account.accountInfo);
+      If isValid And (FSearchValues.onlyForSaleOrSwap) then begin
+        isValid := TAccountComp.IsAccountForSaleOrSwap(account.accountInfo);
       end;
       end;
       If IsValid and (FSearchValues.onlyForPublicSale) then begin
       If IsValid and (FSearchValues.onlyForPublicSale) then begin
         isValid := TAccountComp.IsAccountForPublicSale(account.accountInfo);
         isValid := TAccountComp.IsAccountForPublicSale(account.accountInfo);
       end;
       end;
       If IsValid and (FSearchValues.onlyForPrivateSaleToMe) then begin
       If IsValid and (FSearchValues.onlyForPrivateSaleToMe) then begin
-        isValid := ((TAccountComp.IsAccountForPrivateSale(account.accountInfo) OR
-                    TAccountComp.IsAccountForAccountSwap(account.accountInfo)) AND
-                    (Assigned(FSearchValues.inWalletKeys)) And (FSearchValues.inWalletKeys.IndexOfAccountKey(account.accountInfo.new_publicKey)>=0)) OR
-                    (True {TODO: TAccountComp.IsAccountForCoinSwap(account.accountInfo) AND account.accountInfo.account_to_pay in [MyListOfAccounts]});
+        isValid := (
+          (TAccountComp.IsAccountForPrivateSale(account.accountInfo) OR (TAccountComp.IsAccountForAccountSwap(account.accountInfo)))
+          and
+          (Assigned(FSearchValues.inWalletKeys))
+          and
+          (FSearchValues.inWalletKeys.IndexOfAccountKey(account.accountInfo.new_publicKey)>=0)
+          );
       end;
       end;
       If IsValid then begin
       If IsValid then begin
         IsValid := (account.balance>=FSearchValues.minBal) And ((FSearchValues.maxBal<0) Or (account.balance<=FSearchValues.maxBal));
         IsValid := (account.balance>=FSearchValues.minBal) And ((FSearchValues.maxBal<0) Or (account.balance<=FSearchValues.maxBal));
@@ -267,6 +270,7 @@ begin
 end;
 end;
 
 
 procedure TFRMAccountSelect.FormCreate(Sender: TObject);
 procedure TFRMAccountSelect.FormCreate(Sender: TObject);
+var LColumns : TAccountColumnArray;
 begin
 begin
   FSearchThread := TSearchThread.Create(false);
   FSearchThread := TSearchThread.Create(false);
   FSearchThread.OnSearchFinished := OnSearchFinished;
   FSearchThread.OnSearchFinished := OnSearchFinished;
@@ -279,6 +283,23 @@ begin
   FAccountsGrid := TAccountsGrid.Create(Self);
   FAccountsGrid := TAccountsGrid.Create(Self);
   FAccountsGrid.DrawGrid := dgAccounts;
   FAccountsGrid.DrawGrid := dgAccounts;
   FAccountsGrid.OnUpdated:=OnAccountsGridUpdated;
   FAccountsGrid.OnUpdated:=OnAccountsGridUpdated;
+  FAccountsGrid.AllowMultiSelect := False;
+
+  SetLength(LColumns,6);
+  LColumns[0].ColumnType := act_account_number;
+  LColumns[0].width := 75;
+  LColumns[1].ColumnType := act_name;
+  LColumns[1].width := 80;
+  LColumns[2].ColumnType := act_balance;
+  LColumns[2].width := 80;
+  LColumns[3].ColumnType := act_n_operation;
+  LColumns[3].width := 40;
+  LColumns[4].ColumnType := act_type;
+  LColumns[4].width := 40;
+  LColumns[5].ColumnType := act_saleprice;
+  LColumns[5].width := 45;
+
+  FAccountsGrid.SetColumns( LColumns );
   //
   //
   cbMyAccounts.OnClick:=cbMyAccountsClick;
   cbMyAccounts.OnClick:=cbMyAccountsClick;
   cbMyPrivateKeys.OnClick:=cbMyAccountsClick;
   cbMyPrivateKeys.OnClick:=cbMyAccountsClick;
@@ -476,7 +497,7 @@ begin
   end else begin
   end else begin
     cbMyPrivateKeys.Font.Color := clGray;
     cbMyPrivateKeys.Font.Color := clGray;
   end;
   end;
-  searchValues.onlyForSale := (cbOnlyForSale.Checked);
+  searchValues.onlyForSaleOrSwap := (cbOnlyForSale.Checked);
   searchValues.onlyForPrivateSaleToMe := (cbOnlyForPrivateSaleToMe.Checked);
   searchValues.onlyForPrivateSaleToMe := (cbOnlyForPrivateSaleToMe.Checked);
   If searchValues.onlyForPrivateSaleToMe then begin
   If searchValues.onlyForPrivateSaleToMe then begin
     searchValues.inWalletKeys := FWalletKeys;
     searchValues.inWalletKeys := FWalletKeys;
@@ -508,7 +529,7 @@ begin
     ebAccountName.Font.Color := clGray;
     ebAccountName.Font.Color := clGray;
   end;
   end;
   If (searchValues.inAccountKey.EC_OpenSSL_NID=0) AND (searchValues.inWalletKeys=Nil) And (searchValues.maxBal<0) And (searchValues.minBal<=0) And
   If (searchValues.inAccountKey.EC_OpenSSL_NID=0) AND (searchValues.inWalletKeys=Nil) And (searchValues.maxBal<0) And (searchValues.minBal<=0) And
-     (Not searchValues.onlyForPrivateSaleToMe) And (Not searchValues.onlyForPublicSale) And (Not searchValues.onlyForSale) And
+     (Not searchValues.onlyForPrivateSaleToMe) And (Not searchValues.onlyForPublicSale) And (Not searchValues.onlyForSaleOrSwap) And
      (Length(searchValues.searchName)=0) then begin
      (Length(searchValues.searchName)=0) then begin
     FAccountsGrid.AccountsGridDatasource := acds_Node;
     FAccountsGrid.AccountsGridDatasource := acds_Node;
     lblAccountsCount.Caption := IntToStr(FAccountsGrid.Node.Bank.SafeBox.AccountsCount);
     lblAccountsCount.Caption := IntToStr(FAccountsGrid.Node.Bank.SafeBox.AccountsCount);

+ 1 - 1
src/gui-classic/UGridUtils.pas

@@ -735,7 +735,7 @@ begin
               DrawGrid.Canvas.Font.Color := clGrayText
               DrawGrid.Canvas.Font.Color := clGrayText
             end;
             end;
           end else s := '';
           end else s := '';
-          Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
+          Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfLeft,tfVerticalCenter,tfSingleLine]);
         end;
         end;
       else
       else
         s := '(???)';
         s := '(???)';