Ignore:
Timestamp:
Feb 11, 2022, 11:31:42 AM (3 years ago)
Author:
chronos
Message:
  • Fixed: Do not update interface in contact properties if the listview doesn't have handle yet.
  • Added: Synced update of full name and name parts in contact form.
  • Modified: Improved image loading code by image format.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormContact.pas

    r104 r108  
    205205    procedure ButtonWorkAddressShowClick(Sender: TObject);
    206206    procedure EditFullNameChange(Sender: TObject);
     207    procedure NamePartChange(Sender: TObject);
    207208    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    208209    procedure FormCreate(Sender: TObject);
     
    315316  {$ENDIF}
    316317  Core.PersistentForm1.Load(Self);
    317 
    318   FormProperties.ManualDock(TabSheetAll, nil, alClient);
    319   FormProperties.Align := alClient;
    320   FormProperties.Show;
    321 
    322318  PhotoChange(nil);
    323319
    324   PageControlContact.TabIndex := Core.LastContactTabIndex;
    325   UpdateInterface;
     320  FormProperties.BeginUpdate;
     321  try
     322
     323    FormProperties.ManualDock(TabSheetAll, nil, alClient);
     324    FormProperties.Align := alClient;
     325    FormProperties.Show;
     326
     327    PageControlContact.TabIndex := Core.LastContactTabIndex;
     328    UpdateInterface;
     329  finally
     330    FormProperties.EndUpdate;
     331  end;
    326332end;
    327333
     
    385391procedure TFormContact.TabSheetAllShow(Sender: TObject);
    386392begin
    387   FormProperties.Properties := Contact.Properties;
    388   FormProperties.ReloadList;
    389   FormProperties.UpdateInterface;
     393  FormProperties.BeginUpdate;
     394  try
     395    FormProperties.Properties := Contact.Properties;
     396    FormProperties.ReloadList;
     397    FormProperties.UpdateInterface;
     398    FormProperties.Show;
     399  finally
     400    FormProperties.EndUpdate;
     401  end;
    390402end;
    391403
     
    709721end;
    710722
     723procedure UpdateEditNoOnChange(Edit: TEdit; Text: string);
     724var
     725  LastHandler: TNotifyEvent;
     726begin
     727  LastHandler := Edit.OnChange;
     728  Edit.OnChange := nil;
     729  try
     730    Edit.Text := Text;
     731  finally
     732    Edit.OnChange := LastHandler;
     733  end;
     734end;
     735
    711736procedure TFormContact.EditFullNameChange(Sender: TObject);
    712 begin
     737var
     738
     739  Before, First, Middle, Last, After: string;
     740begin
     741  Contact.FullNameToNameParts(EditFullName.Text, Before, First, Middle, Last, After);
     742  UpdateEditNoOnChange(EditTitleBefore, Before);
     743  UpdateEditNoOnChange(EditFirstName, First);
     744  UpdateEditNoOnChange(EditMiddleName, Middle);
     745  UpdateEditNoOnChange(EditLastName, Last);
     746  UpdateEditNoOnChange(EditTitleAfter, After);
    713747  UpdateInterface;
     748end;
     749
     750procedure TFormContact.NamePartChange(Sender: TObject);
     751begin
     752  UpdateEditNoOnChange(EditFullName, Contact.NamePartsToFullName(EditTitleBefore.Text,
     753    EditFirstName.Text, EditMiddleName.Text, EditLastName.Text, EditTitleAfter.Text));
    714754end;
    715755
     
    732772
    733773procedure TFormContact.UpdateInterface;
    734 begin
    735   Caption := EditFullName.Text + ' - ' + SContact;
     774var
     775  Title: string;
     776begin
     777  Title := SContact;
     778  if EditFullName.Text <> '' then Title := EditFullName.Text + ' - ' + Title
     779  else
     780  if EditOrganization.Text <> '' then Title := EditOrganization.Text + ' - ' + Title;
     781  Caption := Title;
    736782  APhotoSave.Enabled := FPhoto.Used;
    737783  APhotoClear.Enabled := FPhoto.Used;
Note: See TracChangeset for help on using the changeset viewer.