Ignore:
Timestamp:
Dec 3, 2021, 7:44:05 PM (3 years ago)
Author:
chronos
Message:
  • Added: Clone context menu action for list of contacts and contact properties.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormProperties.pas

    r42 r51  
    1515  TFormProperties = class(TForm)
    1616    AAdd: TAction;
     17    AClone: TAction;
    1718    ASelectAll: TAction;
    1819    ARemove: TAction;
     
    2627    MenuItem3: TMenuItem;
    2728    MenuItem4: TMenuItem;
     29    MenuItem5: TMenuItem;
    2830    PopupMenuField: TPopupMenu;
    2931    StatusBar1: TStatusBar;
     
    3335    ToolButton3: TToolButton;
    3436    procedure AAddExecute(Sender: TObject);
     37    procedure ACloneExecute(Sender: TObject);
    3538    procedure AModifyExecute(Sender: TObject);
    3639    procedure ARemoveExecute(Sender: TObject);
     
    7881
    7982procedure TFormProperties.ListView1Data(Sender: TObject; Item: TListItem);
     83
     84  procedure AddItem(Text: string; IsCaption: Boolean = False);
     85  begin
     86    if IsCaption then begin
     87      if Text <> '' then Item.Caption := Text
     88        else Item.Caption := ' ';
     89    end else begin
     90      if Text <> '' then Item.SubItems.Add(Text)
     91        else Item.SubItems.Add(' ');
     92    end;
     93  end;
     94
    8095begin
    8196  if Item.Index < ListViewSort1.List.Count then
    8297  with TContactProperty(ListViewSort1.List[Item.Index]) do begin
    83     Item.Caption := Name;
    84     Item.SubItems.Add(Attributes.DelimitedText);
    85     Item.SubItems.Add(Value);
     98    AddItem(Name, True);
     99    AddItem(Attributes.DelimitedText);
     100    AddItem(Value);
    86101    Item.Data := ListViewSort1.List[Item.Index];
    87102  end;
     
    204219end;
    205220
     221procedure TFormProperties.ACloneExecute(Sender: TObject);
     222var
     223  FormProperty: TFormProperty;
     224  ContactProperty: TContactProperty;
     225begin
     226  FormProperty := TFormProperty.Create(nil);
     227  try
     228    ContactProperty := TContactProperty.Create;
     229    ContactProperty.Assign(TContactProperty(ListView1.Selected.Data));
     230    FormProperty.ContactProperty := ContactProperty;
     231    try
     232      if FormProperty.ShowModal = mrOK then begin
     233        Properties.Add(ContactProperty);
     234        ContactProperty := nil;
     235        Core.DataFile.Modified := True;
     236        ReloadList;
     237        UpdateInterface;
     238      end;
     239    finally
     240      if Assigned(ContactProperty) then
     241        ContactProperty.Free;
     242    end;
     243  finally
     244    FormProperty.Free;
     245  end;
     246end;
     247
    206248procedure TFormProperties.AModifyExecute(Sender: TObject);
    207249var
Note: See TracChangeset for help on using the changeset viewer.