Changeset 52 for trunk


Ignore:
Timestamp:
Dec 3, 2021, 8:50:43 PM (3 years ago)
Author:
chronos
Message:
  • Fixed: Wrong object reference to contact Parent after Merge files action.
  • Modified: Optimized select all action.
Location:
trunk
Files:
8 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 = <   
  • trunk/Languages/vCardStudio.cs.po

    r51 r52  
    602602msgstr "Kategorie"
    603603
     604#: ucontact.scontacthasnoparent
     605msgid "Contact has no parent"
     606msgstr "Kontakt nemá rodiče"
     607
    604608#: ucontact.sdayofbirth
    605609msgid "Day of birth"
     
    871875msgstr "Soubor"
    872876
     877#: uformcontacts.sendupdatetoolow
     878msgid "Update counter error"
     879msgstr "Chyba čítače aktualizací"
     880
    873881#: uformcontacts.sfiltered
    874882msgctxt "uformcontacts.sfiltered"
  • trunk/Languages/vCardStudio.po

    r51 r52  
    590590msgstr ""
    591591
     592#: ucontact.scontacthasnoparent
     593msgid "Contact has no parent"
     594msgstr ""
     595
    592596#: ucontact.sdayofbirth
    593597msgid "Day of birth"
     
    859863msgstr ""
    860864
     865#: uformcontacts.sendupdatetoolow
     866msgid "Update counter error"
     867msgstr ""
     868
    861869#: uformcontacts.sfiltered
    862870msgctxt "uformcontacts.sfiltered"
  • trunk/UContact.pas

    r46 r52  
    143143  SFoundBlockEndWithoutBlockStart = 'Found block end without block start';
    144144  SFieldIndexNotDefined = 'Field index not defined';
     145  SContactHasNoParent = 'Contact has no parent';
    145146  SLastName = 'Last Name';
    146147  SFirstName = 'First Name';
     
    478479var
    479480  I: Integer;
    480 begin
     481  C: Integer;
     482begin
     483  C := Count;
    481484  I := 0;
    482485  while (I < Count) and (Items[I].Index <> Index) do Inc(I);
     
    502505  Field: TContactField;
    503506begin
     507  if not Assigned(Parent) then raise Exception.Create(SContactHasNoParent);
    504508  Prop := GetProperty(Index);
    505509  if Assigned(Prop) then begin
     
    517521  I: Integer;
    518522begin
     523  if not Assigned(Parent) then raise Exception.Create(SContactHasNoParent);
    519524  Field := Parent.Fields.GetByIndex(Index);
    520525  if Assigned(Field) then begin
     
    542547function TContact.GetProperty(Index: TContactFieldIndex): TContactProperty;
    543548var
    544   Prop: TContactProperty;
    545549  Field: TContactField;
    546550begin
     551  if not Assigned(Parent) then raise Exception.Create(SContactHasNoParent);
    547552  Field := Parent.Fields.GetByIndex(Index);
    548553  if Assigned(Field) then begin
     
    555560  I: Integer;
    556561begin
    557   Parent := Source.Parent;
    558562  while Properties.Count < Source.Properties.Count do
    559563    Properties.Add(TContactProperty.Create);
     
    568572  I: Integer;
    569573begin
     574  if not Assigned(Parent) then raise Exception.Create(SContactHasNoParent);
    570575  Result := False;
    571576  for I := 0 to Parent.Fields.Count - 1 do begin
  • trunk/UCore.pas

    r49 r52  
    374374        if not Assigned(NewContact) then begin
    375375          NewContact := TContact.Create;
     376          NewContact.Assign(TempFile.Contacts[I]);
    376377          NewContact.Parent := TContactsFile(DataFile);
    377           NewContact.Assign(TempFile.Contacts[I]);
    378378          TContactsFile(DataFile).Contacts.Add(NewContact);
    379379          Inc(Result.New);
Note: See TracChangeset for help on using the changeset viewer.