Changeset 68 for trunk


Ignore:
Timestamp:
Dec 10, 2021, 11:15:41 AM (3 years ago)
Author:
chronos
Message:
  • Fixed: Wrong field selected for duplicates find from field combobox selection in Find duplicates window.
  • Added: Sort list of contact fields in Find duplicates and Field windows.
Location:
trunk
Files:
6 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormFindDuplicity.pas

    r29 r68  
    4949  public
    5050    FoundItems: TFoundItems;
    51     ContactField: TContactFieldIndex;
     51    ContactFieldIndex: TContactFieldIndex;
    5252    procedure Find;
    5353    procedure ReloadList;
     
    107107
    108108procedure TFormFindDuplicity.SetContacts(AValue: TContacts);
     109var
     110  ContactField: TContactField;
    109111begin
    110112  if FContacts = AValue then Exit;
     
    112114  if Assigned(FContacts) then begin
    113115    Contacts.ContactsFile.Fields.LoadToStrings(ComboBoxField.Items);
    114     ComboBoxField.ItemIndex := Integer(ContactField);
     116    ContactField := Contacts.ContactsFile.Fields.GetByIndex(ContactFieldIndex);
     117    ComboBoxField.ItemIndex := ComboBoxField.Items.IndexOfObject(ContactField);
    115118    if (ComboBoxField.Items.Count > 0) and (ComboBoxField.ItemIndex = -1) then
    116119      ComboBoxField.ItemIndex := 0;
     
    133136  FoundItems.Clear;
    134137  for I := 0 to Contacts.Count - 1 do begin
    135     FieldName := TContact(Contacts[I]).Fields[ContactField];
     138    FieldName := Contacts[I].Fields[ContactFieldIndex];
    136139    if FieldName <> '' then begin
    137140      Item := FoundItems.SearchByField(FieldName);
     
    153156  Core.Translator.TranslateComponentRecursive(Self);
    154157  Core.ThemeManager1.UseTheme(Self);
    155   ContactField := cfTelCell;
     158  ContactFieldIndex := cfTelCell;
    156159end;
    157160
    158161procedure TFormFindDuplicity.ComboBoxFieldChange(Sender: TObject);
    159162begin
    160   ContactField := TContactFieldIndex(ComboBoxField.ItemIndex);
     163  if ComboBoxField.ItemIndex <> -1 then
     164    ContactFieldIndex := TContactField(ComboBoxField.Items.Objects[ComboBoxField.ItemIndex]).Index
     165    else ContactFieldIndex := cfTelCell;
    161166  Find;
    162167end;
  • trunk/Forms/UFormProperty.lfm

    r56 r68  
    9595  object ComboBoxField: TComboBox
    9696    Left = 168
    97     Height = 42
     97    Height = 41
    9898    Top = 24
    9999    Width = 532
  • trunk/Forms/UFormProperty.pas

    r56 r68  
    6464begin
    6565  if ComboBoxField.ItemIndex <> -1 then begin
    66     Field := TContactsFile(Core.DataFile).Fields[ComboBoxField.ItemIndex];
     66    Field := TContactField(ComboBoxField.Items.Objects[ComboBoxField.ItemIndex]);
    6767    if Assigned(Field) then begin
    6868      EditName.Text := Field.SysName;
     
    132132    GroupsArray);
    133133  if Assigned(Field) then
    134     ComboBoxField.ItemIndex := TContactsFile(Core.DataFile).Fields.IndexOf(Field);
     134    ComboBoxField.ItemIndex := ComboBoxField.Items.IndexOfObject(Field);
    135135end;
    136136
  • trunk/Packages/Common/UCommon.pas

    r22 r68  
    8585function TryHexToInt(Data: string; var Value: Integer): Boolean;
    8686function TryBinToInt(Data: string; var Value: Integer): Boolean;
     87procedure SortStrings(Strings: TStrings);
    8788
    8889
     
    677678end;
    678679
     680procedure SortStrings(Strings: TStrings);
     681var
     682  Tmp: TStringList;
     683begin
     684  Strings.BeginUpdate;
     685  try
     686    if Strings is TStringList then begin
     687      TStringList(Strings).Sort;
     688    end else begin
     689      Tmp := TStringList.Create;
     690      try
     691        Tmp.Assign(Strings);
     692        Tmp.Sort;
     693        Strings.Assign(Tmp);
     694      finally
     695        Tmp.Free;
     696      end;
     697    end;
     698  finally
     699    Strings.EndUpdate;
     700  end;
     701end;
     702
    679703
    680704initialization
  • trunk/UContact.pas

    r66 r68  
    162162
    163163uses
    164   UQuotedPrintable;
     164  UQuotedPrintable, UCommon;
    165165
    166166const
     
    674674  I: Integer;
    675675begin
    676   while AItems.Count < Count do AItems.Add('');
    677   while AItems.Count > Count do AItems.Delete(AItems.Count - 1);
    678   for I := 0 to Count - 1 do
    679     AItems[I] := Items[I].Title;
     676  AItems.BeginUpdate;
     677  try
     678    while AItems.Count < Count do AItems.Add('');
     679    while AItems.Count > Count do AItems.Delete(AItems.Count - 1);
     680    for I := 0 to Count - 1 do begin
     681      AItems.Objects[I] := Items[I];
     682      AItems[I] := Items[I].Title;
     683    end;
     684    SortStrings(AItems);
     685  finally
     686    AItems.EndUpdate;
     687  end;
    680688end;
    681689
Note: See TracChangeset for help on using the changeset viewer.