Changeset 108 for trunk/Forms


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.
Location:
trunk/Forms
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormContact.lfm

    r103 r108  
    4343        Top = 75
    4444        Width = 161
     45        OnChange = NamePartChange
    4546        ParentFont = False
    4647        TabOrder = 1
     
    9596      end
    9697      object EditLastName: TEdit
    97         Left = 699
     98        Left = 700
    9899        Height = 43
    99100        Top = 75
    100101        Width = 161
     102        OnChange = NamePartChange
    101103        ParentFont = False
    102104        TabOrder = 2
     
    167169        Top = 125
    168170        Width = 161
     171        OnChange = NamePartChange
    169172        ParentFont = False
    170173        TabOrder = 4
     
    179182      end
    180183      object EditTitleBefore: TEdit
    181         Left = 375
     184        Left = 376
    182185        Height = 43
    183186        Top = 175
    184187        Width = 161
     188        OnChange = NamePartChange
    185189        ParentFont = False
    186190        TabOrder = 5
     
    199203        Top = 175
    200204        Width = 161
     205        OnChange = NamePartChange
    201206        ParentFont = False
    202207        TabOrder = 6
     
    699704        Width = 920
    700705        Caption = 'Address'
    701         ClientHeight = 255
     706        ClientHeight = 281
    702707        ClientWidth = 918
    703708        TabOrder = 9
  • 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;
  • trunk/Forms/UFormContacts.pas

    r104 r108  
    260260  Selected: Boolean;
    261261begin
     262  if not ListView1.HandleAllocated then Exit;
     263
    262264  Selected := Assigned(ListView1.Selected);
    263265  AAdd.Enabled := Assigned(Contacts);
  • trunk/Forms/UFormMain.lfm

    r90 r108  
    11object FormMain: TFormMain
    2   Left = 601
     2  Left = 553
    33  Height = 829
    4   Top = 447
     4  Top = 401
    55  Width = 1227
    66  Caption = 'vCard Studio'
  • trunk/Forms/UFormProperties.pas

    r104 r108  
    6565  private
    6666    FProperties: TContactProperties;
     67    FUpdateCount: Integer;
    6768    procedure FilterList(List: TFPGObjectList<TObject>);
    6869    procedure SetProperties(AValue: TContactProperties);
     70    procedure DoUpdateInterface;
    6971  public
    7072    property Properties: TContactProperties read FProperties write SetProperties;
    7173    procedure ReloadList;
     74    procedure BeginUpdate;
     75    procedure EndUpdate;
    7276    procedure UpdateInterface;
    7377  end;
     
    9397  STextFiles = 'Text files';
    9498  SValue = 'Value';
     99  SEndUpdateTooLow = 'Update counter error';
    95100
    96101const
     
    365370end;
    366371
    367 procedure TFormProperties.UpdateInterface;
     372procedure TFormProperties.BeginUpdate;
     373begin
     374  Inc(FUpdateCount);
     375end;
     376
     377procedure TFormProperties.EndUpdate;
     378begin
     379  if FUpdateCount <= 0 then raise Exception(SEndUpdateTooLow);
     380  Dec(FUpdateCount);
     381  if FUpdateCount = 0 then DoUpdateInterface;
     382end;
     383
     384procedure TFormProperties.DoUpdateInterface;
    368385var
    369386  Text: string;
     
    371388  Selected: Boolean;
    372389begin
     390  if not ListView1.HandleAllocated then Exit;
     391
    373392  Selected := Assigned(ListView1.Selected);
    374393  AAdd.Enabled := Assigned(Properties);
     
    392411end;
    393412
     413procedure TFormProperties.UpdateInterface;
     414begin
     415  if FUpdateCount = 0 then DoUpdateInterface;
     416end;
     417
    394418end.
    395419
Note: See TracChangeset for help on using the changeset viewer.