Changeset 52 for trunk/Forms


Ignore:
Timestamp:
Dec 3, 2021, 8:50:43 PM (2 years ago)
Author:
chronos
Message:
  • Fixed: Wrong object reference to contact Parent after Merge files action.
  • Modified: Optimized select all action.
Location:
trunk/Forms
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormContact.lfm

    r49 r52  
    2525    object TabSheetGeneral: TTabSheet
    2626      Caption = 'General'
    27       ClientHeight = 744
    28       ClientWidth = 931
     27      ClientHeight = 742
     28      ClientWidth = 929
    2929      OnHide = TabSheetGeneralHide
    3030      OnShow = TabSheetGeneralShow
     
    298298    object TabSheetHome: TTabSheet
    299299      Caption = 'Home'
    300       ClientHeight = 744
    301       ClientWidth = 931
     300      ClientHeight = 742
     301      ClientWidth = 929
    302302      OnHide = TabSheetHomeHide
    303303      OnShow = TabSheetHomeShow
     
    394394        Anchors = [akTop, akLeft, akRight]
    395395        Caption = 'Address'
    396         ClientHeight = 212
    397         ClientWidth = 888
     396        ClientHeight = 215
     397        ClientWidth = 890
    398398        TabOrder = 6
    399399        object Label36: TLabel
     
    538538    object TabSheetWork: TTabSheet
    539539      Caption = 'Work'
    540       ClientHeight = 744
    541       ClientWidth = 931
     540      ClientHeight = 742
     541      ClientWidth = 929
    542542      OnHide = TabSheetWorkHide
    543543      OnShow = TabSheetWorkShow
     
    616616        Width = 911
    617617        Caption = 'Address'
    618         ClientHeight = 217
    619         ClientWidth = 907
     618        ClientHeight = 220
     619        ClientWidth = 909
    620620        TabOrder = 4
    621621        object Label31: TLabel
     
    827827    object TabSheetOthers: TTabSheet
    828828      Caption = 'Others'
    829       ClientHeight = 744
    830       ClientWidth = 931
     829      ClientHeight = 742
     830      ClientWidth = 929
    831831      OnHide = TabSheetOthersHide
    832832      OnShow = TabSheetOthersShow
  • trunk/Forms/UFormContacts.lfm

    r51 r52  
    1414  object ListView1: TListView
    1515    Left = 0
    16     Height = 801
     16    Height = 810
    1717    Top = 0
    1818    Width = 1210
     
    5858    Left = 0
    5959    Height = 39
    60     Top = 833
     60    Top = 842
    6161    Width = 1210
    6262    Align = alBottom
     
    9090    Left = 0
    9191    Height = 32
    92     Top = 801
     92    Top = 810
    9393    Width = 1210
    9494    OnChange = ListViewFilter1Change
     
    9797  object StatusBar1: TStatusBar
    9898    Left = 0
    99     Height = 36
    100     Top = 872
     99    Height = 27
     100    Top = 881
    101101    Width = 1210
    102102    Panels = <   
  • trunk/Forms/UFormContacts.pas

    r51 r52  
    5353  private
    5454    FContacts: TContacts;
     55    FUpdateCount: Integer;
    5556    procedure FilterList(List: TFPGObjectList<TObject>);
    5657    procedure SetContacts(AValue: TContacts);
    5758    procedure FormContactPrevious(Sender: TObject);
    5859    procedure FormContactNext(Sender: TObject);
     60    procedure DoUpdateInterface;
    5961  public
    6062    property Contacts: TContacts read FContacts write SetContacts;
    6163    procedure ReloadList;
     64    procedure BeginUpdate;
     65    procedure EndUpdate;
    6266    procedure UpdateInterface;
    6367  end;
     
    8084  SFiltered = 'Filtered';
    8185  SSelected = 'Selected';
     86  SEndUpdateTooLow = 'Update counter error';
    8287
    8388{ TFormContacts }
     
    99104  if Item.Index < ListViewSort1.List.Count then
    100105  with TContact(ListViewSort1.List[Item.Index]) do begin
    101 
    102106    AddItem(Fields[cfFullName], True);
    103107    AddItem(Fields[cfFirstName]);
     
    220224end;
    221225
     226procedure TFormContacts.DoUpdateInterface;
     227var
     228  Text: string;
     229  SelectedCount: Integer;
     230begin
     231  AAdd.Enabled := Assigned(Contacts);
     232  AModify.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected);
     233  ARemove.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected);
     234
     235  Text := '';
     236  if Assigned(Contacts) then begin
     237    Text := STotal + ': ' + IntToStr(Contacts.Count);
     238    if ListView1.Items.Count < Contacts.Count then
     239      Text := Text + ', ' + SFiltered + ': ' + IntToStr(ListView1.Items.Count);
     240    SelectedCount := ListView1.SelCount;
     241    if SelectedCount > 0 then
     242      Text := Text + ', ' + SSelected + ': ' + IntToStr(SelectedCount);
     243  end;
     244  StatusBar1.Panels[0].Text := Text;
     245end;
     246
    222247procedure TFormContacts.FormShow(Sender: TObject);
    223248begin
     
    268293    Contact := TContact.Create;
    269294    try
     295      Contact.Parent := Contacts.ContactsFile;
    270296      Contact.Assign(TContact(ListView1.Selected.Data));
    271297      FormContact.Contact := Contact;
     
    297323    Contact := TContact.Create;
    298324    try
     325      Contact.Parent := Contacts.ContactsFile;
    299326      Contact.Assign(TContact(ListView1.Selected.Data));
    300327      FormContact.Contact := Contact;
     
    333360
    334361procedure TFormContacts.ASelectAllExecute(Sender: TObject);
    335 begin
    336   ListView1.SelectAll;
    337   UpdateInterface;
     362var
     363  I: Integer;
     364begin
     365  BeginUpdate;
     366  ListView1.BeginUpdate;
     367  for I := 0 to ListView1.Items.Count - 1 do
     368    ListView1.Items[I].Selected := True;
     369  //ListView1.SelectAll;
     370  ListView1.EndUpdate;
     371  EndUpdate;
    338372end;
    339373
     
    360394end;
    361395
     396procedure TFormContacts.BeginUpdate;
     397begin
     398  Inc(FUpdateCount);
     399end;
     400
     401procedure TFormContacts.EndUpdate;
     402begin
     403  if FUpdateCount <= 0 then raise Exception(SEndUpdateTooLow);
     404  Dec(FUpdateCount);
     405  if FUpdateCount = 0 then DoUpdateInterface;
     406end;
     407
    362408procedure TFormContacts.UpdateInterface;
    363 var
    364   Text: string;
    365   SelectedCount: Integer;
    366 begin
    367   AAdd.Enabled := Assigned(Contacts);
    368   AModify.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected);
    369   ARemove.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected);
    370 
    371   Text := '';
    372   if Assigned(Contacts) then begin
    373     Text := STotal + ': ' + IntToStr(Contacts.Count);
    374     if ListView1.Items.Count < Contacts.Count then
    375       Text := Text + ', ' + SFiltered + ': ' + IntToStr(ListView1.Items.Count);
    376     SelectedCount := ListView1.SelCount;
    377     if SelectedCount > 0 then
    378       Text := Text + ', ' + SSelected + ': ' + IntToStr(SelectedCount);
    379   end;
    380   StatusBar1.Panels[0].Text := Text;
     409begin
     410  if FUpdateCount = 0 then DoUpdateInterface;
    381411end;
    382412
  • trunk/Forms/UFormProperties.lfm

    r51 r52  
    1414  object ListView1: TListView
    1515    Left = 0
    16     Height = 801
     16    Height = 810
    1717    Top = 0
    1818    Width = 1210
     
    4646    Left = 0
    4747    Height = 39
    48     Top = 833
     48    Top = 842
    4949    Width = 1210
    5050    Align = alBottom
     
    7373    Left = 0
    7474    Height = 32
    75     Top = 801
     75    Top = 810
    7676    Width = 1210
    7777    OnChange = ListViewFilter1Change
     
    8080  object StatusBar1: TStatusBar
    8181    Left = 0
    82     Height = 36
    83     Top = 872
     82    Height = 27
     83    Top = 881
    8484    Width = 1210
    8585    Panels = <   
Note: See TracChangeset for help on using the changeset viewer.